如何给NSWindow一个特定的背景颜色 [英] How to give NSWindow a particular background color
本文介绍了如何给NSWindow一个特定的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在写一个有一个NSWindow的可可应用程序。我想将窗口的背景颜色更改为特定颜色。但是检查器中的窗口属性仅提供纹理窗口替代方案。如何根据需要制作窗口的颜色?
I am writing a cocoa application which has a NSWindow. I want to change the background color of the window to a specific color. But the window properties in the inspector only provide "Textured Window" alternative. How can I make the color of the window as desired?
推荐答案
尝试使用窗口上的颜色调用实例方法setBackgroundColor:实例。什么是名字..;)
Try calling the instance method setBackgroundColor: with a color on your window instance. What's in a name.. ;)
像这样:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Option 1
[self.window setBackgroundColor: NSColor.whiteColor];
// Option 2 - using dot syntax
self.window.backgroundColor = NSColor.whiteColor;
}
这篇关于如何给NSWindow一个特定的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文