I just create a UICollectionView, but when I set cell color, I got a strange result, can you tell me why?
Code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
static NSString *kCellID = @"Cell";
WordCell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID forIndexPath:indexPath];
cell.label.text = [NSString stringWithFormat:@"%i%i", indexPath.section, indexPath.row];
switch (indexPath.row) {
case 0:
case 1:
case 4:
case 5:
cell.backgroundColor = [UIColor greenColor];
break;
case 2:
case 3:
case 6:
cell.backgroundColor = [UIColor redColor];
break;
default:
break;
}
return cell;
}