0

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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Madu
  • 4,849
  • 9
  • 44
  • 78
  • Please look at the docs for colorWithRed:green:blue:alpha:, and note the values the parameters take. – rdelmar Jun 23 '14 at 15:12
  • You need to divide by 255.0 Please refer to this article http://stackoverflow.com/questions/5641523/using-uicolor-colorwithredgreenbluealpha-doesnt-work-with-uitableview-sep – pqteru Jun 23 '14 at 15:13

1 Answers1

1

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];
Alexander
  • 7,178
  • 8
  • 45
  • 75