I'm working on an OS X app that involves popovers with web views in them. The web views have drawsBackground
set to NO
. Sometimes there are buttons in these popovers, on top of the web views. These buttons have custom background colors and have their text colors set via NSAttributedString
. But when the Reduce Transparency setting is on in System Preferences, the white text disappears. If the text is any other color, it shows up - even clear (though faintly).
See here for an example project on GitHub demonstrating the problem.
What is going on here?
Update: I talked to an engineer at WWDC 2016 about this, and he confirmed it was a bug. I filed a radar. He did manage to fix it in my code by setting the appearance of the button in question to NSAppearanceNameAqua
.
The issue doesn't have anything to do with your web view. I removed the web view from its super view and the issue persists. The issue is related to using layers. If you comment out button.wantsLayer = YES, the issue doesn't happen anymore, but then you don't have a background color. If you're only using layers to set a background color, there are other ways to accomplish this without the use of layers.
[(NSButtonCell *)button.cell setBackgroundColor:[NSColor colorWithRed:112.0f / 255 green:107.0f / 255 blue:151.0f / 255 alpha:1]];
When you add a layer, it sits on top of whatever is drawn in the button via its drawRect method. My guess is that when the 'Reduce Transparency' option is turned on, the opacity of the layer of the area where the text is is increased. If you play around with other text colors like yellow, you can see that the actual color is like a grayish yellow which supports my suspicion that the opacity in the area of text is increased.