嗨,我已经在互联网上四处寻找并找到了有关此主题的各种有用信息,但似乎没有一个有效
如果试图得到这样的东西
标题栏和窗口的其余部分融合在一起。从互联网上,iv 到目前为止得到的代码在我的 viewDidLoad() 中
self.view.window?.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
self.view.window?.styleMask = (self.view.window?.styleMask)! | NSFullSizeContentViewWindowMask
self.view.window?.titlebarAppearsTransparent = true
self.view.window?.movableByWindowBackground = true
但这并没有做任何事情。我是 Mac 开发的新手(通常是 ios),所以感谢所有帮助!
最佳答案
创建 NSWindowController
的子类并将代码放在 windowDidLoad() 中。
override func windowDidLoad() {
super.windowDidLoad()
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
self.window?.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
self.window?.styleMask = (self.window?.styleMask)! | NSFullSizeContentViewWindowMask
self.window?.titlebarAppearsTransparent = true
self.window?.movableByWindowBackground = true
}
关于macos - 使用深色透明使标题栏和 View Controller 无缝连接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33007134/