I subclassed NSTableRowView
in view-based NSTableView
to change the selection color to a lighter blue instead of the default one.
Unfortunately when I select the row the color of the labels and textfields inside my custom cell turns white and it's not readable.
How can I prevent text from changing color on selection?
Solution Found:
All I had to do is to implement -setBackgroundStyle:
in my custom NSTableCellView
and there call the setBackgroundStyle:NSBackgroundStyleLight
on the NSCell
of all the controls I want to keep dark on selection.
How did you change the selection color? This sounds like it could have been caused by you adding a subview or sublayer (perhaps to cell.selectedBackgroundView?) on top of the existing layers. If you have any insertSublayer or subView calls, make sure you are doing them atIndex:0.