I've made an NSTableCellView in my nib, which has the textField occupying the entire space, and it works great for displaying text, and tracking the size of the column.
Now I want to be able to set a solid background color for it, in a specific case (i.e., not for all cells). How do I do this?
I think it's like this question, except the solution there didn't do anything for me, and I can't come up with anything close to it that works, either.
I've tried making my -tableView:viewForTableColumn:row:
method...
- set the cellview.layer.backgroundColor
- set cellview.wantsLayer=YES (and confirming that there's a layer)
- set cellview.layer.opaque=YES and cellview.layer.opacity=1.0
- set the cellview.textField.backgroundColor
- set cellview.textField.drawsBackground=YES
- in the nib, for the Table Cell View's Text Field, checked "Draws Background", and set the Background popup (which would be permanent for all table cells, not just for the ones I want in -tableView:viewForTableColumn:row:, but if this worked it would demonstrate to me that at least something here is capable of painting the background)
Since my text takes up the entire cell view, being able to set it on either the textField or the whole cell view would be fine.
This seems like it should be a simple setting somewhere, but nothing works. Do I need to subclass NSTableCellView just to have a background color?
backgound
colour in the inspector panel in interface builder, or in code. In the case of yourUITextField,
declare it as a property and add yourTextfield.backgroundColor = [UIColor blueColor]; inviewdidLoad
– JSA986