views:

427

answers:

3

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

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

+2  A: 

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

Otherwise, you can't. Ever notice how there aren't any Aqua windows with different-colored title bars roaming around in other apps? This is why.

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

Peter Hosey
Ah. How does firefox do it with it's Personas then? I've always been curious.
Nano8Blazex
Oh I see firefox probably built it's own window
Nano8Blazex
+4  A: 

If you set the background color of a "textured" window (a distinction that isn't really all that visible in Snow Leopard) that color will be applied to the titlebar as well. This is what Firefox does.

I would recommend though not having a real titlebar (i.e. setting your window to have no titlebar) and using +[NSWindow standardWindowButton:forStyleMask:] and putting your own buttons in the "titlebar". This allows you more control and is way way less hacky.

Colin Barrett
A: 

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

Pierre Bernard
Don't. Just don't. :( There are better ways.
Colin Barrett