Permalink
Browse files

unbutton set horizontal content alignment

  • Loading branch information...
1 parent 4fff904 commit 7d104381e17e45a0ea3d1f30e19fbce1ec23b34f @ptshih committed Apr 10, 2012
Showing with 16 additions and 0 deletions.
  1. +1 −0 PSStyleSheet.h
  2. +15 −0 PSStyleSheet.m
View
@@ -80,6 +80,7 @@
+ (UIColor *)backgroundColorForStyle:(NSString *)style;
+ (CGSize)shadowOffsetForStyle:(NSString *)style;
+ (UITextAlignment)textAlignmentForStyle:(NSString *)style;
++ (UIControlContentHorizontalAlignment)horizontalAlignmentForStyle:(NSString *)style;
+ (NSInteger)numberOfLinesForStyle:(NSString *)style;
+ (UILineBreakMode)lineBreakModeForStyle:(NSString *)style;
View
@@ -150,6 +150,7 @@ + (void)applyStyle:(NSString *)style forButton:(UIButton *)button {
[button setTitleShadowColor:[PSStyleSheet shadowColorForStyle:style] forState:UIControlStateNormal];
button.titleLabel.font = [PSStyleSheet fontForStyle:style];
button.titleLabel.shadowOffset = [PSStyleSheet shadowOffsetForStyle:style];
+ button.contentHorizontalAlignment = [PSStyleSheet horizontalAlignmentForStyle:style];
}
+ (void)applyStyle:(NSString *)style forTextField:(UITextField *)textField {
@@ -235,6 +236,20 @@ + (UITextAlignment)textAlignmentForStyle:(NSString *)style {
}
}
++ (UIControlContentHorizontalAlignment)horizontalAlignmentForStyle:(NSString *)style {
+ // Defaults to CENTER if undefined
+ if ([[[self class] styleDictForStyle:style] objectForKey:@"textAlignment"]) {
+ NSString *textAlignmentString = [[[self class] styleDictForStyle:style] objectForKey:@"textAlignment"];
+ if ([textAlignmentString isEqualToString:@"center"]) {
+ return UIControlContentHorizontalAlignmentCenter;
+ } else if ([textAlignmentString isEqualToString:@"right"]) {
+ return UIControlContentHorizontalAlignmentRight;
+ } else return UIControlContentHorizontalAlignmentLeft;
+ } else {
+ return UIControlContentHorizontalAlignmentCenter;
+ }
+}
+
#pragma mark - Number of Lines
+ (NSInteger)numberOfLinesForStyle:(NSString *)style {
NSInteger numberOfLines = 0; // If left empty, default to 0

0 comments on commit 7d10438

Please sign in to comment.