《省钱达人》与《猎豆优选》UI相同版。域名tbk

MBProgressHUD+Extension.m 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //
  2. // MBProgressHUD+Extension.m
  3. // djlt
  4. //
  5. // Created by macmini04 on 16/1/18.
  6. // Copyright © 2016年 com.topsage.djlt. All rights reserved.
  7. //
  8. #import "MBProgressHUD+Extension.h"
  9. @implementation MBProgressHUD (Extension)
  10. + (instancetype)showLoadingAddedToView:(UIView *)view {
  11. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  12. hud.label.text = @"加载中";
  13. hud.label.textColor = [UIColor YHColorWithHex:0x333333];
  14. hud.label.font = [UIFont boldSystemFontOfSize:17];
  15. hud.bezelView.backgroundColor = [UIColor whiteColor];
  16. hud.bezelView.layer.cornerRadius = 14;
  17. hud.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.3f];
  18. return hud;
  19. }
  20. + (instancetype)showTip:(NSString *)tip {
  21. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:[UIApplication sharedApplication].keyWindow animated:YES];
  22. hud.mode = MBProgressHUDModeText;
  23. hud.label.text = tip;
  24. hud.label.numberOfLines=0;
  25. hud.label.textColor = [UIColor whiteColor];
  26. hud.label.font = [UIFont boldSystemFontOfSize:17];
  27. hud.bezelView.backgroundColor = [UIColor blackColor];
  28. hud.bezelView.layer.cornerRadius = 14;
  29. hud.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
  30. [hud hideAnimated:YES afterDelay:1.0f];
  31. return hud;
  32. }
  33. /** 显示信息 */
  34. + (MBProgressHUD *)showMessage:(NSString *)message {
  35. return [self showMessage:message toView:nil];
  36. }
  37. + (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view {
  38. if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
  39. // 快速显示一个提示信息
  40. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  41. hud.label.text = message;
  42. hud.mode =MBProgressHUDModeText;
  43. // 隐藏时候从父控件中移除
  44. hud.removeFromSuperViewOnHide = YES;
  45. // 1秒之后再消失
  46. [hud hideAnimated:YES afterDelay:2];
  47. return hud;
  48. }
  49. + (void)show:(NSString *)text icon:(NSString *)icon view:(UIView *)view {
  50. if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
  51. // 快速显示一个提示信息
  52. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  53. hud.label.text = text;
  54. // 设置图片
  55. hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"MBProgressHUD.bundle/%@", icon]]];
  56. // 再设置模式
  57. hud.mode = MBProgressHUDModeCustomView;
  58. // hud.mode = MBProgressHUDModeAnnularDeterminate; // 圆形进度条
  59. // 隐藏时候从父控件中移除
  60. hud.removeFromSuperViewOnHide = YES;
  61. // 1秒之后再消失
  62. [hud hideAnimated:YES afterDelay:1];
  63. }
  64. /** 成功 */
  65. + (void)showSuccess:(NSString *)success {
  66. [self showSuccess:success toView:nil];
  67. }
  68. + (void)showSuccess:(NSString *)success toView:(UIView *)view
  69. {
  70. [self show:success icon:@"success.png" view:view];
  71. }
  72. /** 错误 */
  73. + (void)showError:(NSString *)error {
  74. [self showError:error toView:nil];
  75. }
  76. + (void)showError:(NSString *)error toView:(UIView *)view{
  77. [self show:error icon:@"error.png" view:view];
  78. }
  79. /** 隐藏 */
  80. + (void)hideHUD {
  81. [self hideHUDForView:nil];
  82. }
  83. + (void)hideHUDForView:(UIView *)view {
  84. if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
  85. // 隐藏时候从父控件中移除
  86. [self hideHUDForView:view animated:YES];
  87. }
  88. @end