/WindowReader

📱 Access UIWindow/NSWindow in SwiftUI

Primary LanguageSwiftMIT LicenseMIT

WindowReader

Access the current UIWindow or NSWindow from any SwiftUI view.

Usage

Read the current UIWindow or NSWindow with WindowReader

@main
struct MyView: View {
    var body: some Scene {
        WindowReader { window in
            ...
        }
    }
}

On child views the UIWindow or NSWindow will be available in the Environment

Environment

@Environment(\.window) var window

License

See LICENSE