Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 stylings like it says it will in the HIG.

Thanks!

like image 341
DexterW Avatar asked Aug 21 '11 04:08

DexterW


3 Answers

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/

like image 80
nielspl Avatar answered Nov 15 '22 17:11

nielspl


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.

like image 10
Peter Hosey Avatar answered Nov 15 '22 17:11

Peter Hosey


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:

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

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.

like image 2
Isabel Avatar answered Nov 15 '22 19:11

Isabel