纹理的NSWindow与setBackgroundColor有一个带有灰色背景 [英] Textured NSWindow with setBackgroundColor has a tinged grey background

查看:792
本文介绍了纹理的NSWindow与setBackgroundColor有一个带有灰色背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想做一个简单的窗口,有一个统一的标题栏和窗口(即纹理)和一个白色背景,如Xcode的窗口:



所以我有一个纹理的窗口在IB和我有它连接到我的应用程序代理通过绑定。然后我将这行代码添加到应用程序委托:

  [about setBackgroundColor:[NSColor whiteColor]]; 

虽然对于其他颜色,如红色和蓝色,窗口似乎更改颜色,但每当我使用[ NSColor whiteColor]这个窗口看起来没有什么附近像Xcode的窗口一样耀眼明亮:


有趣的是,当窗口无效时,我最终得到Xcode的白色:



这是一个错误,还是应该看起来真的灰色?白色?

解决方案

我发现了一个教程,使用一个漂亮的ghetto hack来交换框架视图的drawRect: href =http://parmanoir.com/Custom_NSThemeFrame =nofollow noreferrer> http://parmanoir.com/Custom_NSThemeFrame



它不会'/ b>

最后的结果:





编辑:我提交了一个反馈助理报告,而在Yosemite DP 7或Xcode 6.1这个问题似乎是固定的。设置带纹理的窗口的背景颜色现在会生成无色的颜色。


Basically I want to make a simple about window that has a unified title bar and window (i.e textured) and a white background, like Xcode's about window:

So I have a textured window in IB and I have it connected to my app delegate via bindings. I then add this line of code to the app delegate:

[about setBackgroundColor:[NSColor whiteColor]];

Whilst for other colours like red and blue the window seems to change colour fine, but whenever I use [NSColor whiteColor] the window looks nowhere near as dazzlingly bright as Xcode's window:

Interestingly enough, when the window is inactive I end up getting Xcode's white colour:

Is this a bug? Or is it supposed to look really grey? How can I make this window "true white"?

解决方案

I found a tutorial that uses a pretty darn ghetto hack to swap the frame view's drawRect: method: http://parmanoir.com/Custom_NSThemeFrame

It doesn't even require you to subclass NSWindow, but I did it anyway in case I wanted to use it on another window or something.

The final result:

Edit: I submitted a feedback assistant report a while back, and as of either Yosemite DP 7 or Xcode 6.1 this issue seems to be fixed. Setting the background colour of a textured window now produces a non-tinged colour.

这篇关于纹理的NSWindow与setBackgroundColor有一个带有灰色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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