我有一个自定义的UITableViewCell基于它是在哪一行而改变颜色:如何防止自定义UITableViewCells在取消选择时闪烁白色?
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
属性!
如何覆盖取消动画以淡入我的单元格的背景颜色?
我也尝试将tableView.backgroundColor设置为[UIColor clearColor] - 这不起作用。 – oliland