123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // GMTools.m
- // XenonSDK
- //
- // Created by fq on 2021/3/22.
- // Copyright © 2021 SAGESSE. All rights reserved.
- //
- #import "GMTools.h"
- @implementation GMTools
- + (UIViewController *)getViewControl {
-
- UIWindow *window = [[UIApplication sharedApplication].delegate window];
- UIViewController *topViewController = [window rootViewController];
-
- while (true) {
-
- if (topViewController.presentedViewController) {
-
- topViewController = topViewController.presentedViewController;
-
- } else if ([topViewController isKindOfClass:[UINavigationController class]] && [(UINavigationController*)topViewController topViewController]) {
-
- topViewController = [(UINavigationController *)topViewController topViewController];
-
- } else if ([topViewController isKindOfClass:[UITabBarController class]]) {
-
- UITabBarController *tab = (UITabBarController *)topViewController;
- topViewController = tab.selectedViewController;
-
- } else {
- break;
- }
- }
- return topViewController;
- }
- + (BOOL)isIPhoneXSeries {
- BOOL isPhoneX = NO;
- if (@available(iOS 11.0, *)) {
- isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0? YES:NO;
- }
- return isPhoneX;
- }
- @end
|