使标题栏和视图控制器与黑暗透明度保持无缝 [英] Make Title Bar and View Controller seamless with Dark Transparency

查看:82
本文介绍了使标题栏和视图控制器与黑暗透明度保持无缝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我一直在Internet上四处寻找,并且发现了有关该主题的各种有用信息,但似乎都没有作用

Hi so iv been looking all over the internet and have found all kinds of useful information on this topic but none seems to be working

如果试图得到这样的东西

if trying to get something like this

标题栏和窗口其余部分融合在一起的位置.到目前为止,从互联网上获得的代码iv在我的viewDidLoad()

where the title bar and the rest of the window blend. From the internet the code iv got so far is in my 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),因此感谢所有帮助,谢谢!

but that isnt doing anything. Im new to Mac development (normally ios) so all help is appreciated thanks!

推荐答案

制作NSWindowController的子类并将您的代码放在windowDidLoad()中.

Make subclass of NSWindowController and put your code in 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
}

这篇关于使标题栏和视图控制器与黑暗透明度保持无缝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆