UIView+Hint.m 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // UIView+Hint.m
  3. // HCQuanfangtong
  4. //
  5. // Created by qft_Ios_03 on 2018/4/24.
  6. // Copyright © 2018年 qft_Ios_03. All rights reserved.
  7. //
  8. #import "UIView+Hint.h"
  9. @implementation UIView (Hint)
  10. - (void)xb_showHudOfMessage:(NSString *)msg withAfterTime:(float)time{
  11. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
  12. hud.label.text = msg;
  13. [hud hideAnimated:YES afterDelay:time];
  14. }
  15. - (void)xb_showHudOfErrorIconMessage:(NSString *)msg withAfterTime:(float)time{
  16. if (msg.length==0) {
  17. return;
  18. }
  19. //显示提示信息
  20. UIView *view = [[UIApplication sharedApplication].delegate window];
  21. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  22. // Configure for text only and offset down
  23. hud.mode = MBProgressHUDModeText;
  24. hud.bezelView.color=[UIColor blackColor];
  25. hud.label.font=[UIFont systemFontOfSize:14];
  26. hud.label.textColor=[UIColor whiteColor];
  27. hud.label.text= msg;
  28. hud.label.numberOfLines=0;
  29. hud.margin = 10.f;
  30. hud.removeFromSuperViewOnHide = YES;
  31. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  32. [hud hideAnimated:YES];
  33. });
  34. }
  35. - (void)xb_showHudOfSucceedIconMessage:(NSString *)msg withAfterTime:(float)time{
  36. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self animated:YES];
  37. hud.mode = MBProgressHUDModeText;
  38. hud.bezelView.color=[UIColor blackColor];
  39. hud.label.font=[UIFont systemFontOfSize:14];
  40. hud.label.textColor=[UIColor whiteColor];
  41. hud.label.text= msg;
  42. hud.label.numberOfLines=0;
  43. hud.margin = 10.f;
  44. hud.removeFromSuperViewOnHide = YES;
  45. // UIImageView *custom = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"succeed"]];
  46. // hud.customView = custom;
  47. [hud hideAnimated:YES afterDelay:time];
  48. }
  49. - (void)xb_showProgress{
  50. [MBProgressHUD showHUDAddedTo:self animated:YES];
  51. }
  52. - (void)xb_dismiss{
  53. [MBProgressHUD hideHUDForView:self animated:YES];
  54. }
  55. - (void)xb_showSheetWithMessage:(NSString *)msg withAfterTime:(float)time{
  56. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.window animated:YES];
  57. hud.mode = MBProgressHUDModeText;
  58. hud.label.text = msg;
  59. hud.offset = CGPointMake(0.f, 1000000.f);
  60. [hud hideAnimated:YES afterDelay:3.f];
  61. }
  62. @end