How to enforce window aspect ratio for a SwiftUI app on macOS?

Viewed 144

Adding an aspectRatio modifier seems no effect on the window.

WindowGroup {
    ContentView()
        .frame(minWidth: windowSize().minWidth, minHeight: windowSize().minHeight)
        .frame(maxWidth: windowSize().maxWidth, maxHeight: windowSize().maxHeight)
        .aspectRatio(2/1, contentMode: .fill)
}

The definition for the windowSize struct used in the code snippet above

struct windowSize {
    let minWidth : CGFloat = 200
    let minHeight : CGFloat = 100
    let maxWidth : CGFloat = 600
    let maxHeight : CGFloat = 300
}
0 Answers
Related