Change title bar color in cocoa

This must have been asked before, but after Googling I still can't seem to find the answer.

How do I change the color of the title bar (a panel that you can click and drag with close, minimize and maximize buttons) to a different color than the default gray in Cocoa?

+2


a source to share


5 answers


If you set the background color of the "textured" window (which is not exactly what you see on Snow Leopard), that color will be applied to the title too. This is what Firefox does.



I would recommend, although I didn't have a real title bar (ie you didn't have a title box) and using +[NSWindow standardWindowButton:forStyleMask:]

and placing your own buttons in the "title". This allows you more control and is less capable.

+11


a source


If it's a panel , you can change it to black by creating it as a HUD Window .

Otherwise, you can't. Have you ever noticed that other apps don't have Aqua wallpapers with multicolored titles? That's why.



The only other way to change the appearance of the title bar (without relying on private implementation details such as having a frame view) is to make the window borderless and create its title bar and window buttons from scratch.

+3


a source


If you go with Colin's approach to creating a window textured in the UI builder (checkbox in window attributes), enter a string to change the background color of the window you put in that appDelegate function. m file

// In this function ---> - (void) applicationDidFinishLaunching: (NSNotification *) aNotification

// enter this [_wowow setBackgroundColor: NSColor.whiteColor];

+1


a source


If you don't mind a private API, you can subclass NSThemeFrame.

0


a source


Setting the title bar looks transparent

self.window.titlebarAppearsTransparent = YES;

And set the background color of the window as you want

0


a source







All Articles