Access the current UIWindow
or NSWindow
from any SwiftUI view.
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(\.window) var window
See LICENSE