PopupView.m 956 B

1234567891011121314151617181920212223242526272829303132333435
  1. //
  2. // PopupView.m
  3. // Unity-iPhone
  4. //
  5. // Created by duowan123 on 2021/4/28.
  6. //
  7. #import "PopupView.h"
  8. #import "MBProgressHUD.h"
  9. @implementation PopupView
  10. //获取根视图
  11. +(void)showCusHUDA:(NSString*)text{
  12. UIViewController *rootVC = [[UIApplication sharedApplication].delegate window].rootViewController;
  13. UIViewController *parent = rootVC;
  14. while ((parent = rootVC.presentedViewController) != nil ){
  15. rootVC = parent;
  16. }
  17. while ([rootVC isKindOfClass:[UINavigationController class]]){
  18. rootVC = [(UINavigationController *)rootVC topViewController];
  19. }
  20. // NSLog(@"dfd === %@",dfd);
  21. //load...
  22. MBProgressHUD * hud = [MBProgressHUD showHUDAddedTo:rootVC.view animated:YES];
  23. hud.mode = MBProgressHUDModeText;
  24. hud.label.text = text;
  25. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  26. [hud hideAnimated:YES];
  27. });
  28. }
  29. @end