2.1 启动时就限制窗口尺寸
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 创建窗口
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// 设置根控制器
self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[ViewController alloc] init]];
// 限制窗口在mac上的显示大小
UIWindowScene *windowScene = self.window.windowScene;
// 设置窗口标题
windowScene.title = @"mac上显示";
// 设置窗口最大尺寸
windowScene.sizeRestrictions.maximumSize = CGSizeMake(500, 300);
// 设置窗口最小尺寸
windowScene.sizeRestrictions.minimumSize = CGSizeMake(300, 100);
[self.window makeKeyAndVisible];
return YES;
}
@end