UITableViewCell will not work with UIColor colorWithRed

62 Views Asked by At

I have an iOS app with a table view. One problem I am having is that I cannot set the cell background colour with a custom RGB colour.

For example, this will work:

// Set the background colour.
[cell contentView].backgroundColor = [UIColor redColor];

However this on the other hand will not work:

// Set the background colour.
[cell contentView].backgroundColor = [UIColor colorWithRed:(54/255.0) green:(215/255.0) blue:(183/255.0) alpha:1.0];

I don't get why its so darn hard to just set one blumming background colour!... :(

I am really frustrated about this because I have tried quite a few different approaches including:

  • Adding a custom UIView to the background of my cell and setting its background colour.
  • Have tried setting this property in the willDisplayCell method.
  • Have tried both the cell.backgroundColor and cell.contentView and neither will work.

Does the UITableView not support custom RGB colours or something?

0

There are 0 best solutions below