1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CatalystのmacOS用アプリでウィンドウサイズを変更できないようにする

1
Last updated at Posted at 2020-01-30

個人的なメモです。

Xcode 11.3.1
Swift 5
Catalystを使用したmacOS用アプリ開発でウィンドウサイズを変更できないようにしたかった。
下記のコードで実現。

AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        //Window Size の固定
        UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }.forEach { windowScene in
            windowScene.sizeRestrictions?.minimumSize = CGSize(width: 1000, height: 800)
            windowScene.sizeRestrictions?.maximumSize = CGSize(width: 1000, height: 800) 
          } 
        return true
    }

経緯としては、Catalystを使用してMac上でアプリを起動したところ

UIScreen.main.bounds.size

から期待通りのHeightとWidthを取得できなかったから。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?