3
votes

Objective-C/Cocoa noob here. I'd like to make the window color in a little Mac app I'm making white, instead of the default light grey color. What's the proper way to do this?

4

4 Answers

5
votes

From the AppDelegate you can simply invoke the window property

self.window.backgroundColor = [NSColor whiteColor];

otherwise from any point of you application you can call

[[NSApplication sharedApplication] keyWindow].backgroundColor = [NSColor whiteColor];

keyWindow is the currently "on top" window, which is probably the only one if the application is simple. For more complicated scenarios where you need a different window you can use

[[NSApplication sharedApplication] windows]

which will return an array of all the windows owned by the application.

1
votes

In AppDelegate.m you can change the window color by just adding the line :

self.window.backgroundColor = [NSColor whiteColor];
0
votes

In your interface builder in window attributes enable textured now you set whole window with your own color. then you can set your window color

[self.window setBackgroundColor:[NSColor redColor]];
0
votes

try this code,

-(void) awakeFromNib
{
    NSColor *red = [NSColor redColor];
    self.view.window.backgroundColor = red;
}