使用 Dark Transparency 使标题栏和视图控制器无缝衔接
Make Title Bar and View Controller seamless with Dark Transparency
您好,我一直在网上搜索并找到了有关此主题的各种有用信息,但 none 似乎有效
如果想得到这样的东西
标题栏和 window 的其余部分混合在一起。从互联网上得到的代码 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
}
您好,我一直在网上搜索并找到了有关此主题的各种有用信息,但 none 似乎有效
如果想得到这样的东西
标题栏和 window 的其余部分混合在一起。从互联网上得到的代码 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
}