Created
March 6, 2012 01:29
-
-
Save BenBarahona/1982734 to your computer and use it in GitHub Desktop.
MBProgressHUD Mixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)showWithLabelMixed:(id)sender { | |
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; | |
[self.navigationController.view addSubview:HUD]; | |
HUD.delegate = self; | |
HUD.labelText = @"Connecting"; | |
HUD.minSize = CGSizeMake(135.f, 135.f); | |
[HUD showWhileExecuting:@selector(myMixedTask) onTarget:self withObject:nil animated:YES]; | |
} | |
- (void)myMixedTask { | |
// Indeterminate mode | |
sleep(2); | |
// Switch to determinate mode | |
HUD.mode = MBProgressHUDModeDeterminate; | |
HUD.labelText = @"Progress"; | |
float progress = 0.0f; | |
while (progress < 1.0f) | |
{ | |
progress += 0.01f; | |
HUD.progress = progress; | |
usleep(50000); | |
} | |
// Back to indeterminate mode | |
HUD.mode = MBProgressHUDModeIndeterminate; | |
HUD.labelText = @"Cleaning up"; | |
sleep(2); | |
// The sample image is based on the work by www.pixelpressicons.com, http://creativecommons.org/licenses/by/2.5/ca/ | |
// Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) | |
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease]; | |
HUD.mode = MBProgressHUDModeCustomView; | |
HUD.labelText = @"Completed"; | |
sleep(2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment