1、在.h文件中进行声明
/**!
* 启动菊花加载提示
*/
+ (void)startLoadIng;
/**!
* 关闭菊花加载提示
*/
+ (void)hideLoadIng;
+ (void)startLoadIng:(NSString *)text;
2、在.m文件中进行实现
+ (void)startLoadIng:(NSString *)text {
MBProgressHUD *HUD = (MBProgressHUD *)[[UIApplication sharedApplication].keyWindow viewWithTag:MBTAG];if (HUD == nil) {
HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
HUD.tag = MBTAG;
[[UIApplication sharedApplication].keyWindow addSubview:HUD];
}
HUD.userInteractionEnabled = NO;
HUD.mode = MBProgressHUDModeIndeterminate;
HUD.labelText = text;
HUD.labelFont = [UIFont fontWithName:@"HelveticaNeue" size:15.0f];
[HUD show:YES];
HUD.removeFromSuperViewOnHide = YES;
}
// 关闭菊花加载指示
+ (void)hideLoadIng {
MBProgressHUD *HUD = (MBProgressHUD *)[[UIApplication sharedApplication].keyWindow viewWithTag:MBTAG];
HUD.removeFromSuperViewOnHide = YES;
if (HUD != nil) {
[HUD hide:YES];
}
}
使用本方法最好是继承于NSObject,方便在其他的地方使用
我是好人,不用谢谢~~~~