简体   繁体   中英

Setting the minimum and maximum size of a window

如何使用Objective-C库在OS X中设置窗口的最大和最小大小?

[theWindow setMaxSize:windowMaxSize];
[theWindow setMinSize:windowMinSize];

NSWindow Class Reference

In Swift 2 this would be:

myWindow.contentMinSize = NSSize(width: 600, height: 500)
myWindow.contentMaxSize = NSSize(width: 1024, height: 780)

Also according to the Apple docs, contentMinSize takes precedent over setMaxSize.

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/index.html#//apple_ref/occ/instp/NSWindow/contentMaxSize

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM