29

I'm working on an app that has a custom NSView on a NSStatusBar which performs all of the drawing when the user clicks it. But here's the problem, the color I'm currently drawing as the view's background color is not the same as the system blue color.

My app's color:
enter image description here

Twitter's menu item color (system):
enter image description here

As you clearly see, my blue color is way lighter than the system. This is the code I'm currently using (and worked perfectly on versions older than Yosemite):

[[NSColor selectedMenuItemColor] set];
NSRectFill(rect);

I've even tried color picking the menu item's color but it seems like the color is affected by the wallpaper below the menu bar.
Any ideas on how to achieve the system look?

Community
  • 1
  • 1
Pedro Vieira
  • 3,330
  • 3
  • 41
  • 76
  • Are you sure Twitter is using `selectedMenuItemColor`? Maybe they are use something diffrent? – Eun Apr 27 '15 at 15:00
  • I was just showing an example that uses the system color for selected menu bar items, and twitter uses the same color as the other built-in widgets, like Wi-Fi and battery. I've been using `selectedMenuItemColor` on older versions of OS X and always worked as expected, not on Yosemite though. – Pedro Vieira Apr 27 '15 at 17:12

2 Answers2

6

As you said, in Yosemite, docks, status bars etc. are affected by whatever is behind them. Try enabling System Preferences > Accessibility > Display > Reduce Transparency and you'll see what your color looks like without this feature./

simurg
  • 1,208
  • 7
  • 14
2

Here is an idea - Maybe you should use the Vibrancy effect and derive from NSVisualEffectView. I knew that I've seen a very similar thread somewhere here in the past, and it took me quite some time to find it. Here it is:

Trouble matching the vibrant background of a Yosemite NSMenuItem containing a custom view

I think Matthes' answer to that question would lead you to the resolution of your issue. Be sure to check it out. I hope it will help - Good luck and report back!

pkamb
  • 33,281
  • 23
  • 160
  • 191
Plamen G
  • 4,729
  • 4
  • 33
  • 44