Image of an invalid NSStatusBarButton template

I'm trying to move my app to the status bar to use NSStatusBarButton

in Yosemite instead of a custom view, but I can't get the template image to work.

I am setting up NSStatusItem

like this:

self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
self.statusItem.button.imagePosition = NSImageLeft;
self.statusItem.button.target = self;
self.statusItem.button.action = @selector(clickButton:);

      

then i set image and title later like so,

self.statusItem.button.title = [self statusItemTitleForLocation:location];

NSImage *image = [self statusItemImageForLocation:location];
[image setTemplate:YES];
self.statusItem.button.image = image;

      

The images I'm using are PNG files with only black and transparent colors.

This seems to be a pretty random way of displaying it. Sometimes it displays black as intended and going into dark mode will make it look pale. But when you turn off dark mode, the text and image remain white. At other times, the app will launch (with dark mode off) and the text and image will be white and remain white even after switching dark mode to then.

Any ideas?

+3
objective-c cocoa osx-yosemite macos nsstatusitem


source to share


No one has answered this question yet

Check out similar questions:

nineteen
content color of table content
eleven
NSStatusBarButton supports highlighting
nine
Swift: NSStatusItem menu behavior in 10.10 (e.g. only show on right click)
7
NSPopover color inverts to dark Yosemite color
2
Screensaver in OSX Cocoa app
1
Change background color for text editing in NSTableView with dark background
1
Rounded corners NSImage in NSButtonCell
1
NSComboBox + Dark Mode. How do I change the background color of a table?
0
WxPython responsive menu icon for osx dark menu & light menu
0
Cocoa NSStatusItem image - opaque background



All Articles
Loading...
X
Show
Funny
Dev
Pics