How to disable window resizing in swiftui on macOS?

That's pretty much the post. How does one go about locking down window resizing for a mac app with swiftUI?

(I've no intention of this running on anything but macOS, so I don't actually care how it will look on i(Pad)OS.)

I've tried the width/height in the frame parameters, min/max width, etc.

none of that worked.

Post not yet marked as solved Up vote post of johncwelch Down vote post of johncwelch
3.2k views

Replies

I would check out the new windowResizability() modifier available in macOS Ventura. In conjunction with existing modifiers, you could use it to disable window resizing. One way to do this could be:

struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
                .fixedSize()
        }
        .windowResizability(.contentSize)
    }
}

More information can be found here: windowResizability(_:) | Apple Developer Documentation

Add a Comment

Thanks! Took me a hot sec to figure out this wasn't in the contentview file, but once I stopped being dumb, I got this:

struct WiFi_AnalyzerApp: App { //implement AppDelegate custom class so we quit on closing window @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate     var body: some Scene {   WindowGroup {   ContentView() //set up the min/max size   .frame(minWidth: 785, maxWidth: 785, minHeight: 212, maxHeight: 212)   }     //lock it down so you can't change it   .windowResizability(.contentSize)     } }

and it's working exactly as I wanted. Thanks!