MBProgressHUD 的类扩展方法用法
2013-07-08 21:50 甘超波 阅读(3446) 评论(0) 编辑 收藏 举报#import "MBProgressHUD.h" @interface MBProgressHUD (Add) + (void)showError:(NSString *)error toView:(UIView *)view; + (MBProgressHUD *)showMessag:(NSString *)message toView:(UIView *)view; @end #import "MBProgressHUD+Add.h" @implementation MBProgressHUD (Add) #pragma mark 显示错误信息 + (void)showError:(NSString *)error toView:(UIView *)view{ // 快速显示一个提示信息 MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud.labelText = error; // 设置图片 hud.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"alert_failed_icon.png"]] autorelease]; // 再设置模式 hud.mode = MBProgressHUDModeCustomView; // 隐藏时候从父控件中移除 hud.removeFromSuperViewOnHide = YES; // 1秒之后再消失 [hud hide:YES afterDelay:1]; } #pragma mark 显示一些信息 + (MBProgressHUD *)showMessag:(NSString *)message toView:(UIView *)view { // 快速显示一个提示信息 MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES]; hud.labelText = message; // 隐藏时候从父控件中移除 hud.removeFromSuperViewOnHide = YES; // YES代表需要蒙版效果 hud.dimBackground = YES; return hud; } @end
目前我正在专注NLP,请立刻加微信/QQ号 546611623, 免费送你原创《NLP高级执行师》高清视频