Skip to content

Commit

Permalink
Merge branch 'runeb-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
matej committed Aug 12, 2014
2 parents e368a8c + b8ef4c4 commit 7e0bda2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 6 additions & 0 deletions MBProgressHUD.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ typedef void (^MBProgressHUDCompletionBlock)();
*/
@property (MB_STRONG) UIColor* detailsLabelColor;

/**
* The color of the activity indicator. Defaults to [UIColor whiteColor]
* Does nothing on pre iOS 5.
*/
@property (MB_STRONG) UIColor *activityIndicatorColor;

/**
* The progress of the progress indicator, from 0.0 to 1.0. Defaults to 0.0.
*/
Expand Down
26 changes: 17 additions & 9 deletions MBProgressHUD.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ @implementation MBProgressHUD
@synthesize detailsLabelText;
@synthesize progress;
@synthesize size;
@synthesize activityIndicatorColor;
#if NS_BLOCKS_AVAILABLE
@synthesize completionBlock;
#endif
Expand Down Expand Up @@ -175,6 +176,7 @@ - (id)initWithFrame:(CGRect)frame {
self.labelColor = [UIColor whiteColor];
self.detailsLabelFont = [UIFont boldSystemFontOfSize:kDetailsLabelFontSize];
self.detailsLabelColor = [UIColor whiteColor];
self.activityIndicatorColor = [UIColor whiteColor];
self.xOffset = 0.0f;
self.yOffset = 0.0f;
self.dimBackground = NO;
Expand Down Expand Up @@ -479,13 +481,18 @@ - (void)updateIndicators {
BOOL isActivityIndicator = [indicator isKindOfClass:[UIActivityIndicatorView class]];
BOOL isRoundIndicator = [indicator isKindOfClass:[MBRoundProgressView class]];

if (mode == MBProgressHUDModeIndeterminate && !isActivityIndicator) {
// Update to indeterminate indicator
[indicator removeFromSuperview];
self.indicator = MB_AUTORELEASE([[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]);
[(UIActivityIndicatorView *)indicator startAnimating];
[self addSubview:indicator];
if (mode == MBProgressHUDModeIndeterminate) {
if (!isActivityIndicator) {
// Update to indeterminate indicator
[indicator removeFromSuperview];
self.indicator = MB_AUTORELEASE([[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]);
[(UIActivityIndicatorView *)indicator startAnimating];
[self addSubview:indicator];
}
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 50000
[(UIActivityIndicatorView *)indicator setColor:self.activityIndicatorColor];
#endif
}
else if (mode == MBProgressHUDModeDeterminateHorizontalBar) {
// Update to bar determinate indicator
Expand Down Expand Up @@ -671,7 +678,7 @@ - (void)unregisterFromKVO {

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

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
Expand All @@ -683,7 +690,8 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
}

- (void)updateUIForKeypath:(NSString *)keyPath {
if ([keyPath isEqualToString:@"mode"] || [keyPath isEqualToString:@"customView"]) {
if ([keyPath isEqualToString:@"mode"] || [keyPath isEqualToString:@"customView"] ||
[keyPath isEqualToString:@"activityIndicatorColor"]) {
[self updateIndicators];
} else if ([keyPath isEqualToString:@"labelText"]) {
label.text = self.labelText;
Expand Down

0 comments on commit 7e0bda2

Please sign in to comment.