and GitHub on the demo in fact, is the small finishing, when the memo, want to do a complex effect can refer to Mbprogresshud on GitHub demo, writing is also very clear.
Download the MBProgressHUD.h and. m files first and drag them into the project. Address: Mbprogresshud
Here is the code: (Define Mbprogresshud *hud first in the. h file;)
1 //Mode 1. Show directly on view2 3HUD =[[Mbprogresshud ShowHUDAddedTo:self.view Animated:yes] retain]; 4 5 6Hud.Delegate=Self ; 7 8 //Common Settings9 Ten //background color of small rectangle One AHud.color = [Uicolor Clearcolor];//It says there's no background . - - //Text to display the -Hud.labeltext =@"Test"; - - //Detail Text + -Hud.detailslabeltext =@"Test Detail"; + A //is there a Shu hood ? at -Hud.dimbackground =YES; - -[HUD hide:yes Afterdelay:2]; - - //Show Text Only in -Mbprogresshud *hud =[Mbprogresshud ShowHUDAddedTo:self.view Animated:yes]; to +Hud.mode =Mbprogresshudmodetext; - theHud.labeltext =@"Some Message ..."; * $Hud.margin =Ten. F; Panax Notoginseng -Hud.yoffset = Max. F; the +Hud.removefromsuperviewonhide =YES; A the[HUD Hide:yes Afterdelay:3]; +
- //mode 2.initWithView $ $ //Use block - -HUD =[[Mbprogresshud alloc] initWithView:self.view]; the - [Self.view Addsubview:hud]; Wuyi theHud.labeltext =@"Test"; - Wu[HUD Showanimated:yes whileexecutingblock:^{ - AboutNSLog (@"%@",@"Do somethings ...."); $ - [self dotask]; - -} completionblock:^{ A + [HUD Removefromsuperview]; the - [HUD release]; $ the }]; the the //Round progress bar the -HUD =[[Mbprogresshud alloc] initWithView:self.view]; in the [Self.view Addsubview:hud]; the AboutHud.mode =mbprogresshudmodeannulardeterminate; the theHud.Delegate=Self ; the +Hud.labeltext =@"Loading"; - the [HUD showwhileexecuting: @selector (myprogresstask) ontarget:self Withobject:nil Animated:yes]; Bayi the //Custom View the -HUD =[[Mbprogresshud alloc] initWithView:self.view]; - theHud.customview = [[[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"37x-checkmark.png"] ] [autorelease]; the the //Set Custom View mode the -Hud.mode =Mbprogresshudmodecustomview; the theHud.Delegate=Self ; the 94Hud.labeltext =@"completed"; the the [HUD Show:yes]; the 98[HUD hide:yes Afterdelay:3]; About -//Proxy Method:101 102 #pragmaMark-103 104 #pragmaMark HUD's Proxy method, which executes when the HUD is turned off the 106-(void) Hudwashidden: (Mbprogresshud *) HUD107 108 { 109 the [HUD Removefromsuperview]; 111 the [HUD release]; 113 theHUD =Nil; the the } 117 118 Two Task119 - 121 122 123 124 the-(void) dotask{126 127 //Some of the logic you're going to do - 129Sleep2); the 131 } the 133-(void) myprogresstask{134 135 floatProgress =0.0f; 136 137 while(Progress <1.0f) { 138 139Progress + =0.01f; $ 141Hud.progress =progress; 142 143Usleep50000); 144 145 } 146 147}
It's still easy to use.
Mbprogresshud Introduction to use