Last active
June 2, 2023 17:34
-
-
Save andresr-dev/c543760b407ff4b48d624fe1985bb770 to your computer and use it in GitHub Desktop.
This is how to get the current window in iOS
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
extension UIApplication { | |
var window: UIWindow? { | |
guard | |
let scene = connectedScenes.first, | |
let sceneDelegate = scene.delegate as? UIWindowSceneDelegate, | |
let uiWindow = sceneDelegate.window | |
else { | |
return nil | |
} | |
return uiWindow | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment