2014-12-31 17 views
6

Quando si cerca di impostare il livello di finestra nella swift im ottenere Use of unresolved identifier 'window' errore utilizzando:finestra di impostazione Livello Errore Swift OSX

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

o

window.level = NSScreenSaverWindowLevel

Ive Controllato qui How to set window level in Swift

Qui Mac OS X, make a window go over menu bar

Qui NSWindow Class

I cant sembrano per accedere NSViewController o NSWindowController finestra delle proprietà

risposta

4

sottoclasse NSWindowController

in windowDidLoad()

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

+0

http://stackoverflow.com/questions/27396957/keep-window-always-on-top-cocoa-swift/ 27397096 # 27397096 –

10

Aggiornamento per Swift 2:

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

Grazie per l'aggiornamento swift2 – JSA986

3

Aggiornamento per Swift 3:

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

Grazie per aver tradotto la soluzione su Swift 3! :) – ixany

+0

Dovrebbe essere: 'window? .level = Int (CGWindowLevelForKey (CGWindowLevelKey.popUpMenuWindow))' – JSA986

Problemi correlati