Search code examples
cocoanstableviewnsimagensbuttonnstablecellview

Invert button image in selected table view row


What I'd like to have is that when a row in my view-based table view is selected, the images (or button images) get inverted, like in Safari:

Inverted button image in selected table view row

I already have a button with the NSStopProgressFreestandingTemplate image (Stop progress image), but nothing happens when the row is selected. The text correctly becomes white.


Solution

  • It turned out that this problem was caused by the NSTableCellView having a Core Animation Layer. (It's funny to know how many problems can be solved by disabling a CALayer.) I would have never thought of that, so I had to compare the source code of the "buggy" .xib file and of a new one which worked.