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?
Find the view or view controller you want to change the background color of. Open it up in the interface builder and open the Attributes Inspector. Find the background color field and set it to the color you want.
Answer. Press "Windows," type "Paint" and click "Paint" to launch the Paintprogram. ... Click the image's background colorand note that Paint changes the color of the "Color 1" square to match that color. ... Move to the Colors section and click the color you'd like to use to replace the existing background color.
Try calling the instance method setBackgroundColor: with a color on your window instance. What's in a name.. ;)
Like this:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Option 1
[self.window setBackgroundColor: NSColor.whiteColor];
// Option 2 - using dot syntax
self.window.backgroundColor = NSColor.whiteColor;
}
The simplest way to change window background is to set it directly in your .xib file.
No code at all:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With