我有一个自定义 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
属性的!
如何覆盖取消选择动画以淡化为单元格的背景颜色?