提前先封裝一下工具類:Utils繼承NSObject
類方法:調(diào)用工具類 這個可以提前設(shè)定哦
+ (MBProgressHUD *)createHUD
{
UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithWindow:window];
HUD.mode = MBProgressHUDModeText;//這個是選擇彈出的HUD是什么類型(純漢字類型)
//HUD.mode = MBProgressHUDModeCustomView;(帶動畫圈圈的)
HUD.yOffset = 200;//距離中心區(qū)域的高度
HUD.detailsLabelFont = [UIFont boldSystemFontOfSize:17];
[window addSubview:HUD];
[HUD show:YES];
HUD.removeFromSuperViewOnHide = YES;
// HUD.userInteractionEnabled=NO; 用戶的可交互性~
// [HUD hide:YES afterDelay:1];//設(shè)置多久后可消失的
return HUD;
}
在調(diào)用HUD的時候:
第一種
MBProgressHUD *HUD = [Utils createHUD];
HUD.mode = MBProgressHUDModeText;
HUD.labelText = @"可以創(chuàng)建";
[HUD hide:YES afterDelay:1];
第二種 [Utils ShowMBProgressHUDWithTitle:message andImageNmae:nil addView:self.view];