Mbprogresshud Alert Box website address: Https://github.com/jdg/MBProgressHUD
The official website has provided enough examples for us to use, but in the implementation of development, we use only a small part of it. To make it easier to use, expand it below (Category)
Mbprogresshud+nj.h
#import "MBProgressHUD.h"@interfaceMbprogresshud (NJ)+ (void) Showsuccess: (NSString *) Success;+ (void) Showsuccess: (NSString *) Success Toview: (UIView *) view;+ (void) ShowError: (NSString *) error;+ (void) ShowError: (NSString *) error Toview: (UIView *) view;+ (Mbprogresshud *) ShowMessage: (NSString *) message;+ (Mbprogresshud *) ShowMessage: (NSString *) message Toview: (UIView *) view;+ (void) Hidehud;+ (void) Hidehudforview: (UIView *) view;@end
Mbprogresshud+nj.m
#import "mbprogresshud+nj.h"@implementationMbprogresshud (NJ)/** * Display information * * @param text message content * @param icon * @param view displayed in view*/+ (voidShow: (NSString *) Text icon: (NSString *) icon view: (UIView *) view{if(view = nil) view =[[UIApplication sharedapplication].windows Lastobject]; //quick display of a prompt messageMbprogresshud *hud =[Mbprogresshud Showhudaddedto:view Animated:yes]; Hud.labeltext=text; //set up a pictureHud.customview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:[nsstring stringWithFormat:@"mbprogresshud.bundle/%@", Icon]]; //re-set modeHud.mode =Mbprogresshudmodecustomview; //hide time removed from parent controlHud.removefromsuperviewonhide =YES; //1 seconds and then disappear .[HUD Hide:yes Afterdelay:0.7];}/** * Display Success Information * * @param success Information Content*/+ (void) Showsuccess: (NSString *) success{[self showsuccess:success toview:nil];}/** * Display Success Information * * @param success Information content * @param view display information*/+ (void) Showsuccess: (NSString *) Success Toview: (UIView *) view{[self show:success icon:@"Success.png"View:view];}/** * Display error message **/+ (void) ShowError: (NSString *) error{[self showerror:error toview:nil];}/** * Display error message * * @param error message content * @param view needs to display information*/+ (void) ShowError: (NSString *) error Toview: (UIView *) view{[self show:error icon:@"Error.png"View:view];}/** * Display error message * * @param message content * * @return return directly to a mbprogresshud and need to be closed manually*/+ (Mbprogresshud *) ShowMessage: (NSString *) message{return[self showmessage:message toview:nil];}/**/+ (Mbprogresshud *) ShowMessage: (NSString *) message Toview: (UIView *) View {if(view = nil) view =[[UIApplication sharedapplication].windows Lastobject]; //quick display of a prompt messageMbprogresshud *hud =[Mbprogresshud Showhudaddedto:view Animated:yes]; Hud.labeltext=message; //hide time removed from parent controlHud.removefromsuperviewonhide =YES; //Yes represents the need for masking effectsHud.dimbackground =YES; returnHUD;}/** * Manual shutdown Mbprogresshud*/+ (void) hidehud{[self hidehudforview:nil];}/** * Manual off Mbprogresshud * * @param view display Mbprogresshud views*/+ (void) Hidehudforview: (UIView *) view{if(view = nil) view =[[UIApplication sharedapplication].windows Lastobject]; [Self Hidehudforview:view animated:yes];}@end
We can see the above code and also refer to the icon. Directly copy the icon to the past, the final source is provided. Project structure:
The use of the method is very simple.
The Bullet box shows success:
[Mbprogresshud showsuccess:@ " test showsuccess"];
The display of the Bullet box failed:
[Mbprogresshud ShowError:@ " test showerror"];
Bullet box display in load:
[Mbprogresshud showmessage:@ " loading Data ..... " ]; // a few seconds later disappears, of course, here can be changed to network request Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (5.0 * nsec_per_sec)), Dispatch_get_main_queue () , ^{ // Remove HUD [Mbprogresshud Hidehud]; // alert for any new data [Mbprogresshud ShowError:@ " no new data "]; });
Part
SOURCE Download: Http://pan.baidu.com/s/1eQhN7VW
IOS third-party framework-mbprogresshud