Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 829
Hiren Gujarati Avatar asked Jul 20 '19 09:07

Hiren Gujarati


People also ask

How do I enable catalyst on Mac?

In the target settings, click General to view the general settings of the target. In the Deployment Info section, add Mac as a supported device and enable Mac support. Select the Mac checkbox. Xcode displays an “Enable Mac support?” confirmation after you select the Mac checkbox.

What is catalyst for Mac?

With Mac Catalyst, you can make a Mac version of your iPad app. Click the Mac checkbox in your iPad app's project settings to configure the project to build both Mac and iPad versions of your app. The two apps share the same project and source code, making it easy to change your code in one place.


1 Answers

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.

like image 151
marcelosalloum Avatar answered Sep 28 '22 08:09

marcelosalloum