UICollectionviewcell zmienia tło
Jak zmienić tło w komórce, jeśli znam numer sekcji i numer artykułu? Poniższy kod pokazuje, jak próbowałem to zrobić.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CalendarCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath];
cell.titleLabel.text = [NSString stringWithFormat:@"%i",indexPath.item-dayStart+2];
if (indexPath.section == todayMonthSection && indexPath.item == dayPlusShift){
cell.backgroundColor = [UIColor colorWithRed:60.0/255.0 green:162.0/255.0 blue:161.0/255.0 alpha:1];
cell.titleLabel.textColor = [UIColor whiteColor];
}
return cell;
Ale jeśli to zrobię podczas przewijania, pomalowałem nie tylko odpowiednią komórkę.