Swift OSX全屏隐藏状态和停靠

时间:2016-04-04 13:58:19

标签: swift macos menu fullscreen 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)

错误在哪里?

1 个答案:

答案 0 :(得分:1)

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

e.g。

class WindowController: NSWindowController {

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

从全屏开始,顶部没有菜单栏,也没有停靠。

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