Media Technology News
Now that Yosemite (OS X 10.10) is in the wild, you may or may not have tried the new dark ui mode. All this really means is that it will make your dock and menu bar black. You can switch to dark mode by checking off the option in the General section of System Preferences as shown below.
Once you switch to dark mode you may notice that a lot of icons either are invisible or look like crap. For example, the Wallpaper by Behance app that we recently released shows no icon when in dark mode.
The fix doesn’t involve providing an alternate icon for dark mode. The solution is actually ridiculously easy. You simply need to set your status bar icon to be a template image. When you do this OS X will take care of adjusting your icon to different visual modes. Here is some code that shows how to do this:// Load icon var icon = NSImage(named: "statusIcon") // Fixes dark mode icon.setTemplate(true) // Create status item var statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(NSVariableStatusItemLength) // Set with tempalte image statusItem.image = icon
So with that one line of code added you can see that the Behance icon is now inverted whenever the user is in dark mode.
If you are using a custom view instead of an image for the menu bar icon then you will have to do some logic in your drawRect method.