开发者

How to create those black/white icons used in the status bar?

How to create those black/white icons开发者_开发问答 used in the status bar?

I believe it has something to do with the alpha channel of the image but I need to find out how to do that in photoshop or gimp.


Tell the NSImage instance for the icon that it should be a template image. The status item should then draw it the right way automatically.

My original answer follows. It describes how to do the effect manually. On Leopard and later, you don't need to do any of that—just tell the image to be a template image, and it should Just Work.


In the menu extras, it's an effect applied at run time. I think it's the menu extras that do it; in a status item, certainly, it's up to the app.

The menu extra icons, not including keyboard layout icons, are pure black on clear. (Take a look inside the menu extras to see this.) The menu extra and/or the SystemUIServer (in your case, your app) applies a gradient to this: Approximately -10% opacity at the top, to -12% at the bottom.

For your app, this would be easy to do ahead of run time in Opacity. In the layer's main content, fill your shapes with pure black; in the layer's mask, draw a rectangle filled with a gradient taking up the entire 16 by 16 point size of the canvas. Use either white or black for the mask mode; it doesn't matter which, so long as you set the gradient colors to match: For white mode, set the gradient to pure black, 90% to 88% opacity; for black mode, set it to pure white, 90% to 88% opacity.

You can do this at run time as well, using blend modes. Draw a pure-black, 90% to 88% opacity gradient first, then draw the shapes (pure black, 100% opacity) using the Destination In mode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜