Search code examples
iosuitableviewuibackgroundcolor

BackgroundColor of UItableviewCell Notworking


I am setting the Background color of my uitableviewCell like

 cell.contentView.backgroundColor = [UIColor colorWithRed:8.0 green:210.0 blue:11.0 alpha:1.0];

its not working, however, if i do like

 cell.contentView.backgroundColor = [UIColor grayColor];

it works then. Any help


Solution

  • UIColor has to be defined between 0 and 1 to get the RGB value to work (UIColor class reference):

    cell.contentView.backgroundColor = [UIColor colorWithRed:8.0f/255.0f green:210.0f/255.0f blue:11.0f/255.0f alpha:1.0f];