I want to display data on table view cell from database so i want to give the color to cell according to data means for 1st cell gray then next two cell in brown again i wan
If you mean cell's background color, the simplest way to change it:
cell.backgroundView.backgroundColor = [UIColor greenColor];
It looks like:
- (UITableViewCell *) tableView:tableView cellForRowAtIndexPath:indexPath
{
cell = ... // dequeue or initialize cell
switch (criteriaFromDatabase)
{
case 0:
cell.backgroundView.backgroundColor = [UIColor greenColor];
break;
case 1:
cell.backgroundView.backgroundColor = [UIColor blueColor];
break;
default:
cell.backgroundView.backgroundColor = [UIColor redColor];
break;
}
return cell;
}