1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //
- // 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;
- }
- + (UIWindow *)getKeyWindow {
-
- UIWindow *mainWindow = nil;
- if (@available(iOS 13.0, *)) {
- mainWindow = [UIApplication sharedApplication].windows.firstObject;
- [mainWindow makeKeyWindow];
- }else {
- mainWindow = [UIApplication sharedApplication].keyWindow;
- }
-
- return mainWindow;
- }
- + (BOOL)isIPhoneXSeries {
- BOOL isPhoneX = NO;
- if (@available(iOS 11.0, *)) {
- isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom > 0.0? YES:NO;
- }
- return isPhoneX;
- }
- @end
|