Reputation: 4168
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?
Upvotes: 3
Views: 4372
Reputation: 1710
try this code,
-(void) awakeFromNib
{
NSColor *red = [NSColor redColor];
self.view.window.backgroundColor = red;
}
Upvotes: 0
Reputation: 990
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]];
Upvotes: 0
Reputation: 3905
In AppDelegate.m you can change the window color by just adding the line :
self.window.backgroundColor = [NSColor whiteColor];
Upvotes: 1
Reputation: 108169
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.
Upvotes: 5