How to hide the initial window on start with OS X storyboards

前端 未结 4 1522
旧巷少年郎
旧巷少年郎 2021-02-07 23:00

I am creating an OS X status bar application, so I want the application to start hidden.

I have created a \"storyboard\" application, and the initial wi

4条回答
  •  名媛妹妹
    2021-02-07 23:32

    This might be a bit of a hack, but you can do this

    func applicationDidFinishLaunching(notification: NSNotification) {
        // Insert code here to initialize your application
        NSApplication.sharedApplication().windows.last!.close()
    }
    

    And then later on...

    NSApplication.sharedApplication().windows.last!.makeKeyAndOrderFront(nil)
    NSApplication.sharedApplication().activateIgnoringOtherApps(true)
    

提交回复
热议问题