Nice images for buttons


I was looking into the NSImage reference, wondering why Xcode didn’t display these funny green, yellow or red bubbles into the Media Library, when I discovered a nice feature about user-defined images for buttons.

When I used my images (for example a fullStopImage.png like â—¼) next to the standard ones, (let’s say a NSGoRightTemplate, â–¶) I noticed than my image looked bad: a plain black square, while the standard image was in nice dark gray, with a emboss effect.

So I used photoshop to get this effect, playing with grays and transparency effects, and finally got something approaching.

Well, I could have saved a couple of hours. if I had spent them by reading the docs.

The colored images from the library are named, for example, “NSAdvanced” or “NSDotMac”. The black/white images always end with “Template”, like “NSGoRightTemplate” or “NSEnterFullScreenTemplate”. I didn’t even notice this before. After all, Apple engineers are fond of long names, aren’t they?

But this “Template” suffix isn’t here just to make a longer name! It tells NSImage to process the black/white image, using it “as a template” to make a new image – with this dark gray tint and the emboss effect! You may define a sharp image with a clear mask and NSImage will make it look as pretty as the system’s one.

The only condition is to end the file name with “Template”.

This feature was introduced with Leopard: I am aware not to announce fresh news. but if this can spare you some time that you could use for sleeping, I’ll be glad.

Thank you Bernard! While I have not used this tutorial yet, I am sure I will use it sooner or later. And besides, I like anyone you values the importance of sleep (something I don’t get much of…)


Nice find, Bernard.