override func viewDidAppear() {
super.viewDidAppear()
self.view.window?.styleMask.remove(.resizable)
}
1、移除
resizable
类型
2、放在viewDidAppear
中
我尝试过放在viewDidLoad
总,无效!
一个比较有意思的事情是:NSWindow.StyleMask
的类型是OptionSet
public struct StyleMask : OptionSet {
public init(rawValue: UInt)
public static var borderless: NSWindow.StyleMask { get }
public static var titled: NSWindow.StyleMask { get }
public static var closable: NSWindow.StyleMask { get }
public static var miniaturizable: NSWindow.StyleMask { get }
public static var resizable: NSWindow.StyleMask { get }
@available(OSX, introduced: 10.2, deprecated: 100000, message: "Textured window style should no longer be used")
public static var texturedBackground: NSWindow.StyleMask { get }
public static var unifiedTitleAndToolbar: NSWindow.StyleMask { get }
@available(OSX 10.7, *)
public static var fullScreen: NSWindow.StyleMask { get }
@available(OSX 10.10, *)
public static var fullSizeContentView: NSWindow.StyleMask { get }
public static var utilityWindow: NSWindow.StyleMask { get }
public static var docModalWindow: NSWindow.StyleMask { get }
public static var nonactivatingPanel: NSWindow.StyleMask { get }
@available(OSX 10.6, *)
public static var hudWindow: NSWindow.StyleMask { get }
}
参照:
https://stackoverflow.com/questions/29338839/non-resizable-window-swift
网友评论