MBProgressHUD+Add.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // MBProgressHUD+Add.m
  3. // 视频客户端
  4. //
  5. // Created by mj on 13-4-18.
  6. // Copyright (c) 2013年 itcast. All rights reserved.
  7. //
  8. #import "MBProgressHUD+Add.h"
  9. @implementation MBProgressHUD (Add)
  10. #pragma mark 显示信息
  11. + (void)show:(NSString *)text icon:(NSString *)icon view:(UIView *)view
  12. {
  13. if (view == nil) view = [UIApplication sharedApplication].keyWindow;
  14. // 快速显示一个提示信息
  15. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  16. hud.label.text = text;
  17. // 设置图片
  18. hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
  19. // 再设置模式
  20. hud.mode = MBProgressHUDModeCustomView;
  21. // 隐藏时候从父控件中移除
  22. hud.removeFromSuperViewOnHide = YES;
  23. // 1秒之后再消失
  24. [hud hideAnimated:YES afterDelay:0.7];
  25. }
  26. #pragma mark 显示错误信息
  27. + (void)showError:(NSString *)error toView:(UIView *)view{
  28. [self show:error icon:@"error.png" view:view];
  29. }
  30. + (void)showSuccess:(NSString *)success toView:(UIView *)view
  31. {
  32. [self show:success icon:@"success.png" view:view];
  33. }
  34. #pragma mark 显示一些信息
  35. + (MBProgressHUD *)showMessag:(NSString *)message toView:(UIView *)view {
  36. if (view == nil) view = [UIApplication sharedApplication].keyWindow;
  37. // 快速显示一个提示信息
  38. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  39. hud.label.text = message;
  40. // 隐藏时候从父控件中移除
  41. hud.removeFromSuperViewOnHide = YES;
  42. // YES代表需要蒙版效果
  43. // hud.dimBackground = YES;
  44. return hud;
  45. }
  46. @end