更改统一的NSToolbar的背景颜色(在优胜美地中) [英] Changing the background color of the unified NSToolbar (in Yosemite)

查看:45
本文介绍了更改统一的NSToolbar的背景颜色(在优胜美地中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个统一的工具栏,因此我找到了这篇文章:

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

  1. 在IB中将窗口设置为带纹理的(我看不到在运行时执行此操作的可能性)

  1. 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的背景颜色(在优胜美地中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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