diff --git a/MBProgressHUD.h b/MBProgressHUD.h index 26eadf6bf..774495332 100755 --- a/MBProgressHUD.h +++ b/MBProgressHUD.h @@ -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. */ diff --git a/MBProgressHUD.m b/MBProgressHUD.m index b53398631..bc0c15173 100755 --- a/MBProgressHUD.m +++ b/MBProgressHUD.m @@ -93,7 +93,9 @@ @implementation MBProgressHUD { @synthesize opacity; @synthesize color; @synthesize labelFont; +@synthesize labelColor; @synthesize detailsLabelFont; +@synthesize detailsLabelColor; @synthesize indicator; @synthesize xOffset; @synthesize yOffset; @@ -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; @@ -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]; @@ -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; @@ -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 { @@ -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];