Tôi có một UITableViewCell tùy chỉnh làm thay đổi màu sắc trên cơ sở đó hàng đó là in:Làm cách nào để ngăn UITableViewCells tùy chỉnh nhấp nháy màu trắng khi bỏ chọn?
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;
}
Tuy nhiên, khi tôi gọi deselectRowAtIndexPath:animated:YES
, các hình ảnh động mất dần đến một màu trắng trong các ô có số selectedBackgroundColor
sẽ tối hơn.
Sau đó tôi nhận ra rằng hoạt ảnh bỏ chọn không liên quan gì đến số selectedBackgroundColor
; trên thực tế, hoạt ảnh deselection thực sự dựa trên thuộc tính tableView.backgroundColor
!
Làm cách nào để ghi đè hoạt ảnh bỏ chọn để làm mờ dần màu nền của các ô?
Tôi cũng đã thử đặt tableView.backgroundColor thành [UIColor clearColor] - điều này không có hiệu lực. – oliland