Skip to content

Instantly share code, notes, and snippets.

@kingiol
Created September 5, 2018 11:14
Show Gist options
  • Save kingiol/ef49309ea594bee7677e0a41832b9973 to your computer and use it in GitHub Desktop.
Save kingiol/ef49309ea594bee7677e0a41832b9973 to your computer and use it in GitHub Desktop.
Get UIWindow
// - (UIWindow *)frontWindow {
// #if !defined(SV_APP_EXTENSIONS)
// NSEnumerator *frontToBackWindows = [UIApplication.sharedApplication.windows reverseObjectEnumerator];
// for (UIWindow *window in frontToBackWindows) {
// BOOL windowOnMainScreen = window.screen == UIScreen.mainScreen;
// BOOL windowIsVisible = !window.hidden && window.alpha > 0;
// BOOL windowLevelSupported = (window.windowLevel >= UIWindowLevelNormal && window.windowLevel <= self.maxSupportedWindowLevel);
// BOOL windowKeyWindow = window.isKeyWindow;
//
// if(windowOnMainScreen && windowIsVisible && windowLevelSupported && windowKeyWindow) {
// return window;
// }
// }
// #endif
// return nil;
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment