У меня есть пользовательская UITableViewCell, которая меняет цвет в зависимости от того, в какой строке она находится:
TableViewController.m
- (void)willDisplayCell:(GSRSongCell *)cell atIndexPath:(NSIndexPath *)indexPath;
{
if (indexPath.row % 2 == 0) {
[cell lighten];
} else {
[cell darken];
}
}
CustomTableViewCell.m
- (void)lighten
{
self.selectedBackgroundView.backgroundColor = [UIColor whiteColor];
self.contentView.backgroundColor = [UIColor whiteColor];
self.primaryLabel.backgroundColor = [UIColor whiteColor];
self.secondaryLabel.backgroundColor = [UIColor whiteColor];
}
- (void)darken
{
UIColor *darkColor = [UIColor colorWithR:241 G:241 B:241 A:1];
self.selectedBackgroundView.backgroundColor = darkColor;
self.contentView.backgroundColor = darkColor;
self.primaryLabel.backgroundColor = darkColor;
self.secondaryLabel.backgroundColor = darkColor;
}
Однако, когда я вызываю deselectRowAtIndexPath:animated:YES
, анимация исчезает до белого цвета в ячейках, где selectedBackgroundColor
должен быть темнее.
Затем я понял, что анимация отмены не имеет ничего общего с selectedBackgroundColor
; на самом деле анимация отмены выбора основана на свойстве tableView.backgroundColor
!
Как переопределить анимацию отмены выбора, чтобы она переходила в цвет фона ячеек?