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!
Thanks!
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
You need to convert your NSColor object into a CGColor struct:
self.layer.backgroundColor = [[NSColor redColor] CGColor];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With