问题描述
我们正在使用Xcode 11中的催化剂,将基于Swift的iOS应用转换为Mac 兼容.
We are converting our Swift based iOS app to Mac compatible using Catalyst in Xcode 11.
当用户调整大小应用程序窗口时,我们在用户界面中遇到问题.那么我们可以禁用调整大小模式并为应用程序窗口提供修复框架吗?
We are facing an issue in UI when user resize app window. So can we disable resize mode and give fix frame for app window?
推荐答案
测试版5将sizeRestrictions
属性添加到 UIWindowScene .
Beta 5 added a sizeRestrictions
property to UIWindowScene.
如果将sizeRestrictions.maximumSize
和sizeRestrictions.minimumSize
设置为相同的值,则该窗口将无法调整大小:
If you set sizeRestrictions.maximumSize
and sizeRestrictions.minimumSize
to the same value, the window will not be resizable:
windowScene.sizeRestrictions?.minimumSize = CGSize(width: 640, height: 480)
windowScene.sizeRestrictions?.maximumSize = CGSize(width: 640, height: 480)
添加此代码最简单的位置可能是场景委托中的scene(_:willConnectTo:options:)
.传入的scene
对象是UIWindowScene
,因此只需将其强制转换然后设置sizeRestrictions
.
The easiest place to add this code is probably scene(_:willConnectTo:options:)
in your scene delegate. The scene
object passed in is a UIWindowScene
, so just cast it and then set sizeRestrictions
.
注意:sizeRestrictions
仅在iOS 10.15 Beta 5中可用.此代码将在较早的Beta中崩溃.
Note: sizeRestrictions
are only available in iOS 10.15 Beta 5. This code will crash in older betas.
这篇关于Xcode 11-在催化剂快速中禁用调整大小模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!