GMTools.m 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // GMTools.m
  3. // XenonSDK
  4. //
  5. // Created by fq on 2021/3/22.
  6. // Copyright © 2021 SAGESSE. All rights reserved.
  7. //
  8. #import "GMTools.h"
  9. @implementation GMTools
  10. + (UIViewController *)getViewControl {
  11. UIWindow *window = [[UIApplication sharedApplication].delegate window];
  12. UIViewController *topViewController = [window rootViewController];
  13. while (true) {
  14. if (topViewController.presentedViewController) {
  15. topViewController = topViewController.presentedViewController;
  16. } else if ([topViewController isKindOfClass:[UINavigationController class]] && [(UINavigationController*)topViewController topViewController]) {
  17. topViewController = [(UINavigationController *)topViewController topViewController];
  18. } else if ([topViewController isKindOfClass:[UITabBarController class]]) {
  19. UITabBarController *tab = (UITabBarController *)topViewController;
  20. topViewController = tab.selectedViewController;
  21. } else {
  22. break;
  23. }
  24. }
  25. return topViewController;
  26. }
  27. + (BOOL)isIPhoneXSeries {
  28. BOOL isPhoneX = NO;
  29. if (@available(iOS 11.0, *)) {
  30. isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0? YES:NO;
  31. }
  32. return isPhoneX;
  33. }
  34. @end