美文网首页
获取最后一个Window层

获取最后一个Window层

作者: L_Divano | 来源:发表于2017-10-30 16:45 被阅读0次

    获取最后一个Window层

    + (UIWindow *)lastWindow
    {
        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 <= UIWindowLevelNormal);
            BOOL windowKeyWindow = window.isKeyWindow;
            
            if(windowOnMainScreen && windowIsVisible && windowLevelSupported && windowKeyWindow) {
                return window;
            }
        }
    
        return nil;
    }

    相关文章

      网友评论

          本文标题:获取最后一个Window层

          本文链接:https://www.haomeiwen.com/subject/lsqmpxtx.html