Search code examples
macosuikitios13mac-catalyst

Mac-catalyst - minimum window size for Mac catalyst app


Mac catalyst allows to resize window, is there any way to provide minimum window size for Mac catalyst app?


Solution

  • Just add the following chunk of code to your application:didFinishLaunchingWithOptions method (for UIKit projects) or to scene(_:willConnectTo:options:) (for SwiftUI projects):

    UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.forEach { windowScene in
        windowScene.sizeRestrictions?.minimumSize = CGSize(width: 480, height: 640)
    }
    

    PS: you can also set the maximumSize property there

    PS2: If you set both minimumSize and maximumSize to the same value, the window size will remain static and won't be resizable.