我有一个表格视图,使用自定义单元格,我已经设置了单元格,当您点击它时,文本会在文本上显示突出显示的颜色。
//特定于细胞
NSString *ligneTableau = [NSString stringWithFormat:@"%@", [[table objectAtIndex:indexPath.row] nome]];
cell.label.text = ligneTableau;
cell.label.font = [UIFont fontWithName:@"populaire" size:35];
cell.label.textColor = [UIColor colorWithRed:124.0f/255.0f green:153.0f/255.0f blue:106.0f/255.0f alpha:1.0f];
cell.fondo.image = [UIImage imageNamed: @"cell_ant.png"];
//highlighted Text
cell.label.highlightedTextColor = [UIColor colorWithRed:55.0f/255.0f green:70.0f/255.0f blue:48.0f/255.0f alpha:1.0f];
每件事情都很好,但回到桌面后,文字会突出显示。
我忘记了什么?
答案 0 :(得分:0)
当你回到桌子时,细胞可能仍然被选中。所以一旦回到桌面,你应该设置取消选择。
[cell setSelected:NO];
答案 1 :(得分:0)
在UpdatesTableViewCell
课程中,您可以实施以下方法:
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
[super setHighlighted:highlighted animated:animated];
if (highlighted)
self.label.textColor = [UIColor colorWithRed:55.0f/255.0f green:70.0f/255.0f blue:48.0f/255.0f alpha:1.0f];
else
self.label.textColor = [UIColor colorWithRed:124.0f/255.0f green:153.0f/255.0f blue:106.0f/255.0f alpha:1.0f];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if (selected)
self.label.textColor = [UIColor colorWithRed:55.0f/255.0f green:70.0f/255.0f blue:48.0f/255.0f alpha:1.0f];
else
self.label.textColor = [UIColor colorWithRed:124.0f/255.0f green:153.0f/255.0f blue:106.0f/255.0f alpha:1.0f];
}