init(content: () -> Content)
Overview 概要
Use a Window
as a container for a view hierarchy presented by your app. The hierarchy that you declare as the group’s content serves as a template for each window that the app creates from that group:
@main
struct Mail: App {
var body: some Scene {
WindowGroup {
MailViewer() // Declare a view hierarchy here.
}
}
}
SwiftUI takes care of certain platform-specific behaviors. For example, on platforms that support it, like macOS and iPadOS, users can open more than one window from the group simultaneously. In macOS, users can gather open windows together in a tabbed interface. Also in macOS, window groups automatically provide commands for standard window management.
Every window created from the group maintains independent state. For example, for each new window created from the group the system allocates new storage for any State
or State
variables instantiated by the scene’s view hierarchy.
You typically use a window group for the main interface of an app that isn’t document-based. For document-based apps, use a Document
instead.