Set Background colour on NSTableCellView

cocoa, macos, objective-c

Solution

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

Problem

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!

Original source

Related problems