Dailycode.info

Short solution for short problems

iOS: tableView show different row colors every second row

Just to have a little bit nicer looking tableviews, I implement this little function that show a different color every record:

- (void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

    if (fmod(indexPath.row,2)==0)

    {

        cell.backgroundColor =  [UIColor colorWithRed:210/255.0f green:210/255.0f blue:210/255.0f alpha:1];

    }

}