How do I draw a background like the nstoolbar
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开发者_如何学Python easy way to draw it? Or use the nstoolbar somewhere other than the top of a window?
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.
- 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:]
精彩评论