總結(jié)一下:MBProgressHUD 是很好用的第三方控件,但也有不少地方像我們這種初學(xué)者不知道的地方,留以共勉。代碼如下
+ (void)show:(NSString *)text icon:(NSString *)icon view:(UIView *)view
{
if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
// 快速顯示一個提示信息
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
hud.detailsLabelText = text; 多行顯示
hud.detailsLabelFont = [UIFont systemFontOfSize:16]; 多行顯示時設(shè)置文字大小
//hud.labelText = text; 只能一行顯示
//hud.labelFont = [UIFont systemFontOfSize:14];單行顯示時設(shè)置文字大小
// 設(shè)置圖片
if (icon && icon.length > 0) {
hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
}
// ?只顯示文本
hud.mode = MBProgressHUDModeText;
//hud.mode = MBProgressHUDModeCustomView; 再設(shè)置模式
// 隱藏時候從父控件中移除
hud.removeFromSuperViewOnHide = YES;
// 2秒之后再消失
[hud hide:YES afterDelay:2.0];
}