Skip to content

Instantly share code, notes, and snippets.

@DargonLee
Last active July 6, 2022 02:10
Show Gist options
  • Save DargonLee/6823fffb3d12696ff7aef5435d8f6c20 to your computer and use it in GitHub Desktop.
Save DargonLee/6823fffb3d12696ff7aef5435d8f6c20 to your computer and use it in GitHub Desktop.
通过storyboard创建WindowController
let mainWindow = NSApplication.shared.mainWindow
mainWindow?.isReleasedWhenClosed = true
mainWindow?.close()
let storyboard = NSStoryboard(name: NSStoryboard.Name("Main"), bundle: nil)
let windowVC = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier("RootWindowViewController")) as! NSWindowController
windowVC.window?.makeKeyAndOrderFront(nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment