Last active
September 18, 2018 06:06
-
-
Save ripperhe/80075f8b3b544b0f552e69bb1fb9dc20 to your computer and use it in GitHub Desktop.
iOS APP 中查找显示在最上面的、全屏的、可见的 window(大部分情况都适用)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIWindow *)topFullScreenVisibleWindow | |
{ | |
NSArray *windows = [UIApplication sharedApplication].windows; | |
for (UIWindow *window in windows.reverseObjectEnumerator) { | |
if (window.hidden == YES || window.opaque == NO) { | |
continue; | |
} | |
if (CGRectEqualToRect(window.bounds, [UIScreen mainScreen].bounds) == NO) { | |
continue; | |
} | |
return window; | |
} | |
if ([UIApplication sharedApplication].keyWindow) { | |
return [UIApplication sharedApplication].keyWindow; | |
} | |
if ([[UIApplication sharedApplication].delegate respondsToSelector:@selector(window)]) { | |
return [UIApplication sharedApplication].delegate.window; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment