WindowPlacement
A type which represents a preferred size and position for a window.
Declaration
struct WindowPlacementOverview
When using the Scene.defaultWindowPlacement(_:) modifier, you return an instance of a WindowPlacement in the closure you provide.
When constructing a window placement, many initial parameters are optional. Any value not specified will fall back to the scene’s default behavior and configuration for sizing and positioning it’s windows.
For example, you can use this to position a window 140 points from the bottom of the visible area of the screen:
Window("Status", id: "status") {
StatusView()
}
.windowResizability(.contentSize)
.defaultWindowPlacement { content, context in
let displayBounds = context.defaultDisplay.visibleRect
let size = content.sizeThatFits(.unspecified)
let position = CGPoint(
x: displayBounds.midX - (size.width / 2),
y: displayBounds.maxY - size.height - 140)
return WindowPlacement(position: position, size: size)
}