How do you use the dark vibrancy on an NSWindow?

萝らか妹 提交于 2019-11-30 01:57:44

This will make a dark mode window. Subsequently, everything in the window (including titlebar, toolbar and even dialogue sheets) will become dark.

    let USE_DARK_MODE = true
    if USE_DARK_MODE {
        window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
        window.invalidateShadow()
    }

invalidateShadow doesn't seem required, but sometimes shadow does not work properly if lacked. (OS X 10.10)

I figured that you can subclass NSWindowController. Set the class for your Window Controller in IB to your custom NSWindowController. After that in the windowDidLoad function

self.window?.titlebarAppearsTransparent = true

Also set "Full Size Content View" in the Attribute inspector for the NSWindow.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!