Pedro Vieira
Pedro Vieira

Reputation: 3370

How to access the system selected menu item blue color?

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?

Upvotes: 29

Views: 798

Answers (2)

Plamen G
Plamen G

Reputation: 4759

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!

Upvotes: 2

simurg
simurg

Reputation: 1208

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./

Upvotes: 6

Related Questions