Swift OSX 全屏隐藏状态和停靠

Swift OSX Fullscreen hiding status and dock

有没有办法在全屏模式下隐藏(而不是禁用)OS X 状态栏和停靠栏?

我有这个代码:

 func applicationDidFinishLaunching(aNotification: NSNotification) {
    /* Pick a size for the scene */
    if let scene = MainMenuScene(fileNamed:"GameScene") {

            if let screen = NSScreen.mainScreen() {

                window.setFrame(screen.frame, display: true, animate: true)
                 window.collectionBehavior = NSWindowCollectionBehavior.FullScreenPrimary

 }

NSApplicationPresentationOptions.AutoHideMenuBar
        skView.showsFPS = false
        skView.showsNodeCount = false


        skView.ignoresSiblingOrder = false

        /* Set the scale mode to scale to fit the window */
        scene.scaleMode = .AspectFill

        scene.size = skView.bounds.size
        self.skView!.presentScene(scene)
    }
}

但我收到此错误:

  Failed to set (collectionBehavior) user defined inspected property on (NSWindow)

哪里错了?

您试过在 windowController 中调用 self.window?.toggleFullScreen(true) 吗?

例如

class WindowController: NSWindowController {

    override func windowDidLoad() {
        super.windowDidLoad()
        self.window?.toggleFullScreen(true)
    }
}

全屏启动,顶部没有菜单栏,也没有停靠栏。

或至少 something.window?.toggleFullScreen(true) 其中 true 应该是发件人。