iOS获取最上层Window

let windows = Array(UIApplication.shared.windows.reversed())
        for window in windows {
            let windowOnMainScreen = window.screen == UIScreen.main
            let isWindowVisible = !window.isHidden && window.alpha > 0
            let windowLevelSupport = window.windowLevel == UIWindowLevelNormal
            let isKeyWindow = window.isKeyWindow
            if windowOnMainScreen && isWindowVisible && windowLevelSupport && isKeyWindow {
                return window
            }
        }
        return UIApplication.shared.keyWindow
0 0 vote
Article Rating
Subscribe
提醒
guest
0 评论
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x