NSObject+Hint.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // NSObject+Hint.m
  3. // HCQuanfangtong
  4. //
  5. // Created by qft_Ios_03 on 2018/11/30.
  6. // Copyright © 2018 qft_Ios_03. All rights reserved.
  7. //
  8. #import "NSObject+Hint.h"
  9. #import "MBProgressHUD.h"
  10. @implementation NSObject (Hint)
  11. - (void)xb_showHint:(NSString *)message
  12. afterDismiss:(float)after
  13. withCoding:(void (^)(void))CodeBlock{
  14. UIView *view = [[UIApplication sharedApplication].delegate window];
  15. MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
  16. hud.mode = MBProgressHUDModeText;
  17. hud.bezelView.color = [UIColor blackColor];
  18. hud.label.font = [UIFont systemFontOfSize:14];
  19. hud.label.textColor = [UIColor whiteColor];
  20. hud.label.text = message;
  21. hud.label.numberOfLines = 0;
  22. hud.margin = 10.f;
  23. hud.removeFromSuperViewOnHide = YES;
  24. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(after * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  25. [hud hideAnimated:YES];
  26. CodeBlock();
  27. });
  28. }
  29. @end