user2443164
user2443164

Reputation:

Embossing effect in the menubar for NSStatusItem

I'm developing an application with an icon in the Mac OS status bar.

I add my icon with:

self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
NSBundle *bundle = [NSBundle mainBundle];
NSImage *connectedImage = [[NSImage alloc] initWithContentsOfFile: [bundle pathForResource: @"drawing" ofType: @"pdf"]];
[self.statusItem setImage:disconnectedImage];

It shows up fine but without the traditional embossing (or shadow) effect that Apple system status items have:

You can see on the left my icon, and on the right the Apple icon with the effect.

I have tried different image formats without any luck. The effect is present if I use an internal icon, like that:

[self.statusItem setImage:[NSImage imageNamed:NSImageNameLockLockedTemplate]];

Should I add the effect by myself to the image or is there something obvious I'm missing?

Thank you!

Upvotes: 1

Views: 183

Answers (1)

al45tair
al45tair

Reputation: 4433

You just need to do

[myImage setTemplate:YES];

then the system will do the indent for you.

Upvotes: 1

Related Questions