Contents

windowIdealSize(_:)

Specifies how windows derived form this scene should determine their size when zooming.

Declaration

nonisolated func windowIdealSize(_ idealSize: WindowIdealSize) -> some Scene

Parameters

  • idealSize:

    A value which determines how windows derived from this scene should size themselves when zooming.

Discussion

The default behavior will size the window to its maximum size, or the bounds of the display, whichever is smaller. By overriding this behavior, you can provide a size that is appropriate for the contents of your window.

For example, you can define a window group where the window has an ideal width of 800 points and an ideal height of 600 points:

struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .frame(idealWidth: 800, idealHeight: 600)
        }
        .windowIdealSize(.fitToContent)
    }
}

See Also

Sizing a window