Gareth Jeanne Gareth Jeanne - 3 months ago 19x
Objective-C Question

Set Background colour on NSTableCellView

I am trying to set a background colour on an NSTableCellView, but there doesn't seem to be an way to do this.

Therefor there must be another way to achieve this that i am not aware of, so, if anyone could enlighten me i would be most appreciative!



A NSTableCellView is a NSView, and a NSView has a CALayer, and a CALayer has a backgroundColor. So...

myTableCellView.wantsLayer = YES;  // make the cell layer-backed
myTableCellView.layer.backgroundColor = [[NSColor redColor] CGColor]; // or whatever color you like