设置窗口级别Swift错误OSX

时间:2014-12-31 11:51:51

标签: macos swift window

尝试使用以下内容设置swift即时Use of unresolved identifier 'window'错误时设置窗口级别:

window.level = Int(CGWindowLevelForKey(Int32(kCGScreenSaverWindowLevelKey)))

window.level = NSScreenSaverWindowLevel

Ive经过检查 这里How to set window level in Swift

此处Mac OS X, make a window go over menu bar

此处NSWindow Class

我似乎无法访问NSViewControllerNSWindowController窗口属性

3 个答案:

答案 0 :(得分:10)

Swift 2更新:

panel.level = Int(CGWindowLevelForKey(CGWindowLevelKey.PopUpMenuWindowLevelKey))

答案 1 :(得分:4)

子类NSWindowController

windowDidLoad()

中的

window?.level = Int(CGWindowLevelForKey(Int32(kCGScreenSaverWindowLevelKey)))

答案 2 :(得分:3)

Swift 3更新:

window.level = Int(CGWindowLevelForKey(CGWindowLevelKey.popUpMenuWindow))