1

I have seen that some icons in the Menu Bar have colours, but I can't find a way to color the NSStatusItem I'm working on. I use an image (inside Images.xcassets) with color, but it just tints in white or black. I'm using MacOS 10.10 and Swift. I have also searched Apple documentation with no luck.

Thanks for your time.

aramusss
  • 2,391
  • 20
  • 30

1 Answers1

4

Those status items with color are actually doing it the wrong (old) way. You're supposed to use template images so that the system can apply effects and show it properly in Dark mode. For a template image, the color is ignored. Only the alpha channel matters.

If you really want to defy Apple's recommendation, simply use a non-template image. Don't suffix your image name with "Template" and don't set the template property in code.

From the AppKit release notes for 10.10:

NSStatusItem appearance and Dark Menu support (Section added since WWDC seed)

There are a number of stylistic changes added and supported by NSStatusItem, including appearance changes for Dark Menus. Template images should always be used to ensure correct styling based on the various states the status item can be in (light menu, dark menu, inactive light, inactive dark, selected, disabled, etc). NSStatusBarButton’s appearsDisabled property can be used to give the image a disabled or “off” look without having the item be functionally disabled. …

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • You are correct, i had in code `iconOff?.setTemplate(true)`, making image color useless. So we have to accept that in 10.10 we will not have coloured icons? Isn't there any correct way? Thanks for the information. – aramusss Mar 11 '15 at 18:58