Skip to content

Commit

Permalink
Merge pull request #50 from percysnoodle/label_colors
Browse files Browse the repository at this point in the history
Add labelColor and detailLabelColor to control label colours
  • Loading branch information
matej committed Oct 1, 2013
2 parents 8e0aed0 + 90c1ffc commit a5d34f1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
14 changes: 12 additions & 2 deletions MBProgressHUD.h
Expand Up @@ -388,11 +388,21 @@ typedef void (^MBProgressHUDCompletionBlock)();
*/
@property (MB_STRONG) UIFont* labelFont;

/**
* Font to be used for the details label. Set this property if the default is not adequate.
/**
* Color to be used for the main label. Set this property if the default is not adequate.
*/
@property (MB_STRONG) UIColor* labelColor;

/**
* Font to be used for the details label. Set this property if the default is not adequate.
*/
@property (MB_STRONG) UIFont* detailsLabelFont;

/**
* Color to be used for the details label. Set this property if the default is not adequate.
*/
@property (MB_STRONG) UIColor* detailsLabelColor;

/**
* The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0.
*/
Expand Down
16 changes: 12 additions & 4 deletions MBProgressHUD.m
Expand Up @@ -93,7 +93,9 @@ @implementation MBProgressHUD {
@synthesize opacity;
@synthesize color;
@synthesize labelFont;
@synthesize labelColor;
@synthesize detailsLabelFont;
@synthesize detailsLabelColor;
@synthesize indicator;
@synthesize xOffset;
@synthesize yOffset;
Expand Down Expand Up @@ -180,7 +182,9 @@ - (id)initWithFrame:(CGRect)frame {
self.opacity = 0.8f;
self.color = nil;
self.labelFont = [UIFont boldSystemFontOfSize:kLabelFontSize];
self.labelColor = [UIColor whiteColor];
self.detailsLabelFont = [UIFont boldSystemFontOfSize:kDetailsLabelFontSize];
self.detailsLabelColor = [UIColor whiteColor];
self.xOffset = 0.0f;
self.yOffset = 0.0f;
self.dimBackground = NO;
Expand Down Expand Up @@ -450,7 +454,7 @@ - (void)setupLabels {
label.textAlignment = MBLabelAlignmentCenter;
label.opaque = NO;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.textColor = self.labelColor;
label.font = self.labelFont;
label.text = self.labelText;
[self addSubview:label];
Expand All @@ -461,7 +465,7 @@ - (void)setupLabels {
detailsLabel.textAlignment = MBLabelAlignmentCenter;
detailsLabel.opaque = NO;
detailsLabel.backgroundColor = [UIColor clearColor];
detailsLabel.textColor = [UIColor whiteColor];
detailsLabel.textColor = self.detailsLabelColor;
detailsLabel.numberOfLines = 0;
detailsLabel.font = self.detailsLabelFont;
detailsLabel.text = self.detailsLabelText;
Expand Down Expand Up @@ -663,8 +667,8 @@ - (void)unregisterFromKVO {
}

- (NSArray *)observableKeypaths {
return [NSArray arrayWithObjects:@"mode", @"customView", @"labelText", @"labelFont",
@"detailsLabelText", @"detailsLabelFont", @"progress", nil];
return [NSArray arrayWithObjects:@"mode", @"customView", @"labelText", @"labelFont", @"labelColor",
@"detailsLabelText", @"detailsLabelFont", @"detailsLabelColor", @"progress", nil];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
Expand All @@ -682,10 +686,14 @@ - (void)updateUIForKeypath:(NSString *)keyPath {
label.text = self.labelText;
} else if ([keyPath isEqualToString:@"labelFont"]) {
label.font = self.labelFont;
} else if ([keyPath isEqualToString:@"labelColor"]) {
label.textColor = self.labelColor;
} else if ([keyPath isEqualToString:@"detailsLabelText"]) {
detailsLabel.text = self.detailsLabelText;
} else if ([keyPath isEqualToString:@"detailsLabelFont"]) {
detailsLabel.font = self.detailsLabelFont;
} else if ([keyPath isEqualToString:@"detailsLabelColor"]) {
detailsLabel.textColor = self.detailsLabelColor;
} else if ([keyPath isEqualToString:@"progress"]) {
if ([indicator respondsToSelector:@selector(setProgress:)]) {
[(id)indicator setProgress:progress];
Expand Down

0 comments on commit a5d34f1

Please sign in to comment.