Ich habe eine benutzerdefinierte UITableViewCell, die Farbe ändert, basierend auf welche Zeile es ist in:Wie verhindere ich, dass benutzerdefinierte UITableViewCells beim Abwählen weiß blinken?
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;
}
Allerdings, wenn ich deselectRowAtIndexPath:animated:YES
nennen, die Animation ein schwindet weiße Farbe in Zellen, in denen die selectedBackgroundColor
dunkler sein sollte.
Ich erkannte dann, dass die Abwahl Animation hat nichts mit der selectedBackgroundColor
zu tun; Tatsächlich basiert die Abwahl-Animation tatsächlich auf der Eigenschaft tableView.backgroundColor
!
Wie kann ich die Abwahlanimation überschreiben, um zur Hintergrundfarbe meiner Zellen zu blenden?
Ich habe auch versucht, die TabelleView.backgroundColor auf [UIColor clearColor] setzen - das hat keine Wirkung. – oliland