I want to achieve the effect where one cell of the table view will have blue background, the next one will have white, the next one will have blue again, and then white and
All you need to do is add the following code in your table's view controller implementation file.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row%2 == 0) {
UIColor *altCellColor = [UIColor blackColor];
cell.backgroundColor = altCellColor;
}}
It's then as simple as adding and changing the modulus values.