问题描述
我想要一个统一的工具栏,因此我找到了这篇文章:
I want to have a unified toolbar and therefore I found this post:
self.window.titleVisibility = NSWindowTitleVisibility.Hidden
工作完美.
但是有没有一种方法可以更改工具栏的背景颜色?我尝试使用 self.window.appearance = NSAppearance(名称:NSAppearanceNameVibrantDark)
,但这只会带来一个完整的黑色工具栏(太暗了).我想要一种自定义颜色.
But is there a way to change the background color for the toolbar? I tried with self.window.appearance = NSAppearance(named: NSAppearanceNameVibrantDark)
, but this only brings a complete black toolbar (that's too dark). I want to have a custom color.
推荐答案
此方法有效:
https://stackoverflow.com/a/28692893/2062613
-
在IB中将窗口设置为带纹理的(我看不到在运行时执行此操作的可能性)
Set the window to textured in IB (I don't see a possibility to do it at runtime)
使用此代码:
self.window.titleVisibility = NSWindowTitleVisibility.Hidden
self.window.backgroundColor = NSColor.whiteColor()
更新:
为防止该工具栏在优胜美地中变得透明(如果在工具栏下方具有滚动视图),请使用以下代码:
To prevent, that the toolbar becomes transparent in Yosemite (if you have a scrollview below the Toolbar), use this code:
self.window.appearance = NSAppearance(named: NSAppearanceNameAqua)
这篇关于更改统一的NSToolbar的背景颜色(在优胜美地中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!