Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSPopover color invert in Yosemite dark color

I'm using NSPopover, and when I change the system dock color to dark (Yosemite new feature) some elements in my view invert their color.

For example some labels changes from black to grey, or text fields background changes from white to black. And if I have a view with white background it is now changes to the blurred dark effect.

So two questions:

  1. Can I cancel this behaviour and force the UI to act like in regular mode?

  2. Is there any rules here which element invert their color?

Because it seems that some element changes and some not.

This is my app in Yosemite regular mode:

enter image description here

And this is in Yosemite dark mode:

enter image description here

like image 588
Mario Avatar asked Oct 01 '14 18:10

Mario


2 Answers

It might be a library you're using that's causing this behavior. I just tested on a new project and I couldn't make the NSPopover black no matter how hard I tried.

What libraries are you using ? How did you set up your NSPopover ?

Maybe you could try changing the appearance property of the view ?

view.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];

NSView has the property appearance because it conforms to NSAppearanceCustomization.

Also see NSAppearance.

————————————————————————

Found the solution:

self.popover.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];

the result:

like image 51
inket Avatar answered Nov 12 '22 16:11

inket


There are ways to do this, though I would recommend embracing it. It's not concretely documented what will change and how. But observation will show you what to do. Primarily it requires you do the opposite of opting in. Opting in is using Appkit interface elements as is as well as using the NSColor names provided as system colors and using the NSVisualEffectView. That means to explicitly opt out you need to go around and basically customize views and that mostly means setting explicit colors and occasionally subclassing. Out of the box HUD style popovers and panels would be opting in.

like image 31
uchuugaka Avatar answered Nov 12 '22 17:11

uchuugaka