Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

0002378

Suspended
Original poster
May 28, 2017
675
671
Hello, I have a simple NSSlider with a custom slider cell that colors the bar with nice gradients. This slider renders just the way I like it, when added under a window (and a box with a black background).

regularMode.png


However, when I copy paste the exact same slider onto a popover view (that is shown attached to a status bar button) with the same background color (i.e. black), the cell of the slider (i.e. the portion around the bar) is drawn with a gray-ish color (see image below).

sbMode.png


NOTE - When this popover is shown, the app is in "accessory" mode, i.e. it is now a "status bar app", whereas in the window example, the app is in "regular" mode.

Code:
NSApp.setActivationPolicy(.accessory)

The same popover renders the cell just fine in regular mode. It is only when it is run in "status bar" (or "accessory") mode that this problem occurs.



It is as if, in the window, the slider cell is somehow transparent around the bar (thus revealing the black box color), while in the popover, it is entirely opaque (thus showing the cell background and not its parent view's background color - black).

I know that this has something to do with Alpha/transparency, Core Animation layers, or drawing order, and I read a Core Graphics tutorial, but got absolutely nowhere. I've spent a good 6 hours or so on this, trying all kinds of modifications to the rendering, and now I would really appreciate some help ! Thanks !

(I can post code if necessary)
 
Last edited:
Problem solved ! This one only took about 10 hours of research, ha !

The problem was that my status/dock bar was in dark mode, and when that is the case, some UI elements' colors are inverted. This is default system-level behavior. When I switched to regular mode, I noticed the rendering returned to normal.

So, the simple solution to this problem is to set the appearance of the popover view to "Aqua", not "Inherited (Aqua)". This way, the view will resist any color inversion in response to a change in status bar appearance.

The problem and solution are both described here: https://stackoverflow.com/questions/26148114/nspopover-color-invert-in-yosemite-dark-color
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.