更新的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 –