我正在使用以下内容为我的单元格设置交替的背景颜色:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (![cell isKindOfClass:[AlbumDetailsCell class]]) {
if (indexPath.row % 2 == 0) {
UIColor *color = [UIColor colorWithRed:229/255.0 green:229/255.0 blue:229/255.0 alpha:1.0];
cell.backgroundColor = color;
}
else {
UIColor *color = [UIColor colorWithRed:214/255.0 green:214/255.0 blue:214/255.0 alpha:1.0];
cell.backgroundColor = color;
}
}
}
当我在表格视图中快速滚动时,这会搞砸。如何防止它弄乱颜色?