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
Use below code.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static int alternateColor = 0;
if((alternateColor % 2) == 0 )
{
cell.contentView.backgroundColor = [UIColor whiteColor];
}
else
{
cell.contentView.backgroundColor = [UIColor blackColor];
}
alternateColor++;
}