学习MBProgressHUD

阅读更多
+ (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;
}
//隐藏HUD
[MBProgressHUD hideHUDForView:self.view animated:YES];

你可能感兴趣的:(Cocoa,Objective-C,Mobile)