I created a group of cells that I reuse as a table. All these cells have different UILabel
inside them, and some UIImageView
(nothing covers the full cell).
Setting the background color in IB does not affect (always white or transparent, cannot say which one). But if I press Command-R (simulate an interface), the cell has the correct background color in the simulator.
I tried setting it to tableView:cellForRowAtIndexPath:
but it does not work as I thought.
This is the trick:
cell.contentView.backgroundColor = [UIColor redColor];
but they do not work (even if I set cell.contentView.backgroundColor
to clearColor
):
cell.backgroundView.backgroundColor = [UIColor redColor]; cell.backgroundColor = [UIColor redColor];
I set all layout / font / background elements to IB. Any idea why this is not working in this case?
Why do I need to change the contentView
backgroundColor
and not backgroundView
?
This seems to be a common problem. Can someone please point me in the right direction (finally) to understand how the background colors are processed in the table view cell.
ios iphone cocoa-touch uitableview interface-builder
klemens Nov 10 2018-10-10T00: 00Z
source share