MBProgressHUD+Add.m 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // MBProgressHUD+Add.m
  3. //
  4. // Created by mj on 13-4-18.
  5. // Copyright (c) 2013年 itcast. All rights reserved.
  6. //
  7. #import "MBProgressHUD+Add.h"
  8. @implementation MBProgressHUD (Add)
  9. + (void)show:(NSString *)text icon:(NSString *)icon view:(UIView *)view
  10. {
  11. if (view == nil) view = [UIApplication sharedApplication].keyWindow;
  12. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  13. hud.labelText = text;
  14. hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
  15. hud.mode = MBProgressHUDModeCustomView;
  16. hud.removeFromSuperViewOnHide = YES;
  17. [hud hide:YES afterDelay:0.7];
  18. }
  19. + (void)showError:(NSString *)error toView:(UIView *)view{
  20. [self show:error icon:@"error.png" view:view];
  21. }
  22. + (void)showSuccess:(NSString *)success toView:(UIView *)view
  23. {
  24. [self show:success icon:@"success.png" view:view];
  25. }
  26. + (MBProgressHUD *)showMessag:(NSString *)message toView:(UIView *)view {
  27. if (view == nil) view = [UIApplication sharedApplication].keyWindow;
  28. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  29. hud.labelText = message;
  30. hud.removeFromSuperViewOnHide = YES;
  31. hud.dimBackground = YES;
  32. return hud;
  33. }
  34. @end