Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSButton on NSVisualEffectView: Wrong Background Color

I have a NSVisualEffectView within a NSPopover developed for 10.10.

When subclassing the NSVisualEffectView to have hover background color effect, the borderless button color seems to be different

gray box

I tried setting the backgroundColor of the button cell to clearColor or the same as I used in drawRect: in of the NSVisualEffectView, the former gives wrong color (not filled with blue) and the later still the same with wrong color. (gray box around its border).

CALayer can fix this but is there a way without using it?

Any ideas?

like image 322
Cai Avatar asked Jun 05 '15 06:06

Cai


1 Answers

After much trial and error, this worked for me:

button.wantsLayer = true
button.layer?.backgroundColor = NSColor.clearColor().CGColor

I've got an NSTableView with NSVisualEffectView style. I created a custom NSTableViewCell class and put these lines in its drawRect method.

like image 75
Greg Galloway Avatar answered Oct 15 '22 02:10

Greg Galloway