Mac-catalyst - minimum window size for Mac catalyst app

mac catalyst toolbar
mac catalyst new window
mac catalyst menu bar
mac catalyst right click
mac catalyst keyboard
error: building for mac catalyst requires macos 10.15 or later
mac catalyst window size
ipad apps on mac

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


Just add the following chunk of code to your application:didFinishLaunchingWithOptions method:

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.

Bringing Adaptivity to Mac Catalyst - Geoff Hackworth, Just add the following chunk of code to your application:​didFinishLaunchingWithOptions method: UIApplication.shared.connectedScenes​.compactMap { $0 as? Mac users expect to resize app windows to just about any size from full screen to as small as the app permits.


Here's an expanded version of @marcelosalloum's excellent answer..

Step 1. Open AppDelegate.swift

Step 2. Locate func application(), insert your version of @marcelosalloum's code here (or make a call to a function your create for this, as I did).

Step 3. Optionally assert that your code only run on platforms with the suitable Swift API's (use #available)


Example Code (In AppDelegate.swift)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
    addWindowSizeHandlerForMacOS()

    return true
}

func addWindowSizeHandlerForMacOS() {
    if #available(iOS 13.0, *) {
        UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.forEach { windowScene in
            windowScene.sizeRestrictions?.minimumSize = CGSize(width: 800, height: 1100)
            windowScene.sizeRestrictions?.maximumSize = CGSize(width: 800, height: 1100)
        }
    }
}

Example Screenshot

In my app, I defined a function named addWindowSizeHandlerForMacOS() starting on line 23. Then I called it from application() in AppDelegate.swift (line 18).

Mac Catalyst - iOS - Human Interface Guidelines, Adaptivity on 11" iPad Pro on iPadOS 13: Main Window with Popover modal Xcode 11.4 or later is required to build universal Mac Catalyst apps. Building for Catalyst is equivalent to building for iOS with a minimum deployment version of The app's screens which show dimensions have a Point/Pixels  I am using following code to have a minimum size for my app, It looks something like this: #if targetEnvironment(macCatalyst) Reset macOS Catalyst Window Size to


Implement Objective-C class with this method:

 - (void)setMinimumSize:(CGSize)size {
     id app = NSClassFromString(@"NSApplication");
     id shared = [app valueForKeyPath:@"sharedApplication"];
     id mainWindow = [shared valueForKeyPath:@"mainWindow"];

     NSValue *nssize = [NSValue valueWithCGSize:size];
     [mainWindow setValue:nssize forKeyPath:@"minSize"];
 }

To call from Swift - use bridging header.

sizeRestrictions, When you use Mac Catalyst to create a Mac version of your iPad app, you make your font size in iOS is 17 pt, whereas the most common font size in macOS is 13 pt. Both items are similar to navigation conventions in Mac-style windows. The minimum and maximum size of the app's windows. iOS 13.0+ Mac Catalyst 13.0+ use it to change the default minimum and maximum window sizes for your app.


Objective-C version of @marcelosalloum's answer:

for (UIScene* scene in UIApplication.sharedApplication.connectedScenes) {
    if ([scene isKindOfClass:[UIWindowScene class]]) {
        UIWindowScene* windowScene = (UIWindowScene*) scene;
        windowScene.sizeRestrictions.minimumSize = CGSizeMake(480, 640);
    }
}

Beyond the Checkbox with Catalyst and AppKit, sizeRestrictions. The minimum and maximum size of the app's windows. Availability. iOS 13.0+; Mac Catalyst 13.0+; tvOS 13.0+. Framework. UIKit. On This Page. WWDC 2019 is here, and with it, a new way to write apps on the Mac: Catalyst.Catalyst is the developer-facing name for the technologies — formerly known as Marzipan — bringing iPad apps to the Mac by introducing UIKit and dozens more frameworks from iOS to the platform and unifying the substrate layer between iOS and macOS.


Just add this to your Scene Delegate:

window?.windowScene?.sizeRestrictions?.minimumSize = CGSize(width: 900.0, height: 750.0)

I also added how to set the maximum size as the greatest possible value:

window?.windowScene?.sizeRestrictions?.maximumSize = CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude)

Catalyst Tutorial: Running iPad apps on macOS, Since Apple's making a point to treat Catalyst apps as 'true Mac apps', that frame onscreen, and setting a minimum/maximum window size. 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.


AppVenture, In this Catalyst tutorial, you'll learn how to take an iPad app and Other iOS UI objects that have no macOS equivalent like Multiple windows support is a broad topic that deserves its own The helper forNSToolbar() paints a source image into a new UIImage of that exact size with correct aspect ratio. Mac Catalyst. Native Mac apps built with Mac Catalyst can share code with your iPad apps, and you can add more features just for Mac. In macOS Big Sur, you can create even more powerful versions of your apps and take advantage of every pixel on the screen by running them at native Mac resolution.


Blog - Catalyst, Catalyst ports your iPad apps over to macOS. This guide Everything is Large; Your whole app, when run on macOS, is resized to 77% of the original size. That's all Support for window resizing and full-screen display. on macOS. Next, lets implement the bare minimum needed to display a toolbar. NOTE To support multiple windows in the Mac version of your iPad app, you must support multiple windows on iPad. For guidance, see Mac Catalyst . There are several ways people can open a new window.


Disabling the Mac Zoom/Maximise Button in Catalyst, When you bring your iPad app to Mac, you give people the and go beyond simply displaying your iOS UI in a macOS window. get in Catalyst; there's no way to set minimum/maximum content sizes, window style mask, etc. The Twitter for Mac app takes full advantage of the native Mac features like multiple windows, drag and drop, keyboard shortcuts, and more. See more of what’s happening on a larger screen and easily work alongside your other Mac apps. Explore more Mac Catalyst apps