tags:

views:

26

answers:

2

I am trying to make a custom toolbar to use anywhere. I want the background to look like the gray that the nstoolbar has. The color is used in several places like the top of Safari or Mail.

Does anyone know of an easy way to draw it? Or use the nstoolbar somewhere other than the top of a window?

+1  A: 

You'll want to create an NSGradient with two colors (the "top" and "bottom"), then draw the gradient into the desired rectangle ([self bounds]?). You can get system colors from the NSColor API reference (there are class convenience methods for system colors). I'm not sure exactly which the bar uses, but that should be enough info to get started.

Joshua Nozzi
Thanks. I am familar with NSGradient but Im not sure how to find the correct range of colors. I will start with the system colors.
joels
A: 
  • Open a standard colour picker in any app (say, TextEdit)
  • Switch to Colour Sliders mode, RGB Sliders submode
  • Click the magnifying glass
  • Click the colour you want to check, anywhere on screen
  • Click the small colour wheel next to the “RGB Sliders” popup menu
  • Select Generic RGB (it should be right under Device RGB, which should be selected)
  • Divide the colour components by 255
  • Feed the resulting values to +[NSColor colorWithCalibratedRed:green:blue:alpha:]
Ahruman