更新的Xcode 8斯威夫特3后,下面的代码不再工作斯威夫特3 NSWindowStyleMask
self.view.window?.styleMask = NSTitledWindowMask | NSMiniaturizableWindowMask
请告诉我我如何能解决这个问题?
更新的Xcode 8斯威夫特3后,下面的代码不再工作斯威夫特3 NSWindowStyleMask
self.view.window?.styleMask = NSTitledWindowMask | NSMiniaturizableWindowMask
请告诉我我如何能解决这个问题?
window.styleMask.insert(.fullSizeContentView)
或者
window.styleMask = window.styleMask.union(.fullSizeContentView)
例子:
override func windowDidLoad() {
super.windowDidLoad()
guard let window = window else { return }
window.titlebarAppearsTransparent = true
window.titleVisibility = .hidden
window.styleMask.insert(.fullSizeContentView)
}
如果任何人也有同样的问题,像我一样,这里有SWIFT 3
的工作版本如果使用NSViewController,添加以下内容:如果使用NSWindowController(感谢若昂·奥利维拉贡献)
override func viewDidAppear() {
self.view.window?.styleMask.insert(.titled) /* Enable Title */
self.view.window?.styleMask.insert(.closable) /* Enable Close button */
}
,添加以下内容:
init(){
self.m_window = NSWindow(
contentRect: NSRect(300, 300, width: 500, height: 500),
styleMask: NSWindowStyleMask(rawValue: (NSWindowStyleMask.closable.rawValue | NSWindowStyleMask.titled.rawValue)),
backing: NSBackingStoreType.buffered, defer: false
)
}
**更改X,Y位置,宽度和高度到你喜欢的窗口大小。
https://github.com/lukakerr/NSWindowStyles –