Skip to content

Instantly share code, notes, and snippets.

@erdemildiz
Created May 18, 2022 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdemildiz/845caa559188df9472e8f3b0ba7ae36b to your computer and use it in GitHub Desktop.
Save erdemildiz/845caa559188df9472e8f3b0ba7ae36b to your computer and use it in GitHub Desktop.
SwiftUI check has modal on modal
extension UIApplication {
var currentKeyWindow: UIWindow? {
UIApplication.shared.connectedScenes
.filter { $0.activationState == .foregroundActive }
.map { $0 as? UIWindowScene }
.compactMap { $0 }
.first?.windows
.filter { $0.isKeyWindow }
.first
}
}
@erdemildiz
Copy link
Author

Check If have modal on modal

 guard
    let subviews = UIApplication.shared.currentKeyWindow?.subviews else {
        return
    }
    if subviews.count > 2 {
        // Code
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment