Here is a relatively simple implementation:
In your tableViewController
implement the cellForRow
with something like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"DefaultCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// check if row is odd or even and set color accordingly
if (indexPath.row % 2) {
cell.backgroundColor = [UIColor whiteColor];
}else {
cell.backgroundColor = [UIColor lightGrayColor];
}
return cell;
}