below is my Mbprogresshud-based package
#import <Foundation/Foundation.h> #import "MBProgressHUD.h" @interface mbhudhelper:nsobject/** * Show mbprogress HUD Indicator * API Parameters Description * Atitle Title * amsg Info * aimg picture, for Nil, only show title * D Delay Vanishing time, 0 need to actively hide * Blocke execute code FAST * blo
CkF at the end of the code block * When executing changes the hub needs to call Common_mainfun (afun) */#define HIDDENMBPROGRESSHUD [Mbhudhelper Hiddenmbprogresshud];
+ (void) Hiddenmbprogresshud;
+ (Mbprogresshud *) Mbprogresshud; #define SHOWMBPROGRESSHUD (Atitle, Amsg, aimg, ADIMBG, Adelay) [Mbhudhelper showmbprogresshudtitle:atitle MSG:AMSG image
: Aimg DIMBG:ADIMBG Delay:adelay];
+ (Mbprogresshud *) Showmbprogresshudtitle: (NSString *) atitle msg: (NSString *) amsg
Image: (UIImage *) aimg DIMBG: (BOOL) DIMBG
Delay: (float) D; #define Showmbprogresshudindeterminate (Atitle, Amsg, ADIMBG, adelay) [Mbhudhelper Showmbprogresshudmodeindeterminatetitle:atitle msg:amsgDIMBG:ADIMBG Delay:adelay];
+ (Mbprogresshud *) Showmbprogresshudmodeindeterminatetitle: (NSString *) atitle
Msg: (NSString *) amsg DIMBG: (BOOL) DIMBG
Delay: (float) D; #define Showmbprogresshudcancelindeterminate (Atitle, Amsg, ADIMBG, adelay) [Mbhudhelper
Showmbprogresshudcancelindeterminate:atitle msg:amsg DIMBG:ADIMBG Delay:adelay];
+ (Mbprogresshud *) Showmbprogresshudcancelindeterminate: (NSString *) atitle
Msg: (NSString *) amsg DIMBG: (BOOL) DIMBG
Delay: (float) D;
+ (Mbprogresshud *) Showmbprogresshudtitle: (NSString *) atitle msg: (NSString *) amsg DIMBG: (BOOL) DIMBG ExecuteblOck: (void (^) (Mbprogresshud *hud)) Blocke Finishblock: (void (^) (void)) BLOCKF;
+ (Mbprogresshud *) Showmessag: (NSString *) message;
@end
#import "MBHUDHelper.h" @implementation mbhudhelper static Mbprogresshud *hud = nil;
+ (void) Hiddenmbprogresshud {[HUD hide:yes];
Downloadmanager.cancelview.hidden=yes;
} + (Mbprogresshud *) Mbprogresshud {return HUD;}
+ (Mbprogresshud *) Showmbprogresshudtitle: (NSString *) atitle msg: (NSString *) amsg
Image: (UIImage *) aimg DIMBG: (BOOL) DIMBG
Delay: (float) d {uiviewcontroller *VC = [self topmostcontroller];
if (vc = = nil) {return nil;
} if (nil = = HUD) {HUD = [[Mbprogresshud alloc] initWithView:vc.view];
} [Vc.view Addsubview:hud];
if (Atitle | | amsg) {hud.mode = Mbprogresshudmodetext;
Hud.labeltext = Atitle;
Hud.detailslabeltext = amsg;
} if (aimg) {Uiimageview *img = [[Uiimageview alloc] initwithimage:aimg]; Hud.customview = img;
Hud.mode = Mbprogresshudmodecustomview;
} hud.removefromsuperviewonhide = YES;
Hud.dimbackground = NO;
hud.userinteractionenabled =!DIMBG;
[HUD Show:yes];
if (d > 0) {[HUD hide:yes afterdelay:d];
} return HUD;
} + (Mbprogresshud *) Showmbprogresshudmodeindeterminatetitle: (NSString *) atitle
Msg: (NSString *) amsg DIMBG: (BOOL) DIMBG
Delay: (float) d {uiviewcontroller *VC = [self topmostcontroller];
if (vc = = nil) {return nil;
} if (nil = = HUD) {HUD = [[Mbprogresshud alloc] initWithView:vc.view];
} [Vc.view Addsubview:hud];
Hud.mode = mbprogresshudmodeindeterminate;
Hud.labeltext = Atitle;
Hud.detailslabeltext = amsg;
Hud.removefromsuperviewonhide = YES; Hud.dimbackground = dimbG
[HUD Show:yes];
if (d > 0) {[HUD hide:yes afterdelay:d];
} return HUD;
} + (Mbprogresshud *) Showmbprogresshudcancelindeterminate: (NSString *) atitle
Msg: (NSString *) amsg DIMBG: (BOOL) DIMBG
Delay: (float) d{Uiviewcontroller *VC = [self topmostcontroller];
if (vc = = nil) {return nil;
} if (nil = = HUD) {HUD = [[Mbprogresshud alloc] initWithView:vc.view];
} [Vc.view Addsubview:hud]; if (nil = = Downloadmanager.cancelview) {Downloadmanager.cancelview=[[cancelview alloc] Initwithframe:cgrectmake (KD
EVICEWIDTH-80, 25, 80, 35)];
} Downloadmanager.cancelview.hidden=no;
[Vc.view AddSubview:DownLoadManager.cancelView];
Hud.mode = mbprogresshudmodeindeterminate;
Hud.labeltext = Atitle;
Hud.detailslabeltext = amsg; Hud.remOvefromsuperviewonhide =no;
Hud.dimbackground = DIMBG;
[HUD Show:yes];
if (d > 0) {[HUD hide:yes afterdelay:d];
} return HUD; } + (Mbprogresshud *) Showmbprogresshudtitle: (NSString *) atitle msg: (NSString *) AM SG DIMBG: (BOOL) DIMBG Executeblock: (void (^) (Mbprogresshud *hud)) Blocke Finishblock: (void (^) (void)) Blockf {Uiviewcontroller *VC = [Self Topmostcon
Troller];
if (vc = = nil) {return nil;
} if (nil = = HUD) {HUD = [[Mbprogresshud alloc] initWithView:vc.view];
} [Vc.view Addsubview:hud];
Hud.labeltext = Atitle;
Hud.detailslabeltext = amsg;
Hud.removefromsuperviewonhide = YES;
Hud.dimbackground = DIMBG;
[HUD Showanimated:yes whileexecutingblock:^{Blocke (HUD);
} completionblock:^{//[hud Hide:yes];
BLOCKF ();
}]; return HUD;
} + (Mbprogresshud *) Showmessag: (NSString *) message {Uiviewcontroller *VC = [self topmostcontroller];
if (vc = = nil) {return nil;
} if (nil = = HUD) {HUD = [[Mbprogresshud alloc] initWithView:vc.view];
} [Vc.view Addsubview:hud];
Hud.detailslabeltext = message;
Hud.detailslabelfont = [Uifont systemfontofsize:15];
Hud.mode = Mbprogresshudmodetext;
Hud.removefromsuperviewonhide = YES;
Hud.margin = 10.F;
Hud.linebreakmode = Uilinebreakmodewordwrap;
[HUD Show:yes];
[HUD Hide:yes afterdelay:1.0f];
return HUD;
} @end