开发者

Make NSToolbar Icon for NSToolbar

I'd like to make an icon for my NSToolbar that has the same system stylings applied to it as the template icons in IB. How do you do this? I can't get the toolbar to apply system s开发者_开发技巧tylings like it says it will in the HIG.

Thanks!


In Mac OS X v10.5 or later, images whose name ends in the word "Template" are automatically marked as template images. NSImage Class Reference

NSImage *image = [NSImage imageNamed:@"MyImageTemplate"];

This also works for Interface Builder. More information: http://www.proppe.org/blog/2007/12/01/nsimage-templates/


If you mean for a monochromatic icon, make sure you set it as a template image. That's what tells the system to render it with the inner gray or blue gradient.


The toolbar doesn't do that automatically. You have to create the graphics yourself. The Lion-style icons are usually mid-gray with a subtle inner shadow and a 1px whitish drop shadow. Here's an example done in Photoshop:

Make NSToolbar Icon for NSToolbar

And here's all the layer styling done to it:

Make NSToolbar Icon for NSToolbar


Make NSToolbar Icon for NSToolbar


Make NSToolbar Icon for NSToolbar

The specific numbers and colors may vary depending on the icon's shape and size.

On a side note, the HIG was saying that icons may change depending on the control. For example, when you disable a button, its icon will be displayed semi-transparently.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜