- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
if (selected) {
companyLabel.textColor = [UIColor whiteColor];
priceLabel.textColor = [UIColor whiteColor];
changeLabel.textColor = [UIColor whiteColor];
symbolLabel.textColor = [UIColor whiteColor];
}
else
{
companyLabel.textColor = [UIColor blackColor];
priceLabel.textColor = [UIColor blackColor];
symbolLabel.textColor = [UIColor blackColor];
if([changeLabel.text doubleValue] < 0)
{
changeLabel.textColor = [UIColor colorWithRed:239.0/255.0 green:16.0/255.0 blue:52.0/255.0 alpha:1.0];
}
else if([changeLabel.text doubleValue] > 0)
{
changeLabel.textColor = [UIColor colorWithRed:77.0/255.0 green:161.0/255.0 blue:0.0 alpha:1.0];
}
}
}
在下一个 View 被推送到导航堆栈之前,我的文本不会变白。
我希望它在用户点击并按住一个单元格时变成白色。
最佳答案
UILabel
有一个 highlightedTextColor
属性。当像 UITableViewCell
这样的 View 进入其突出显示状态时,所有 subview (包括您的标签)都应自动更改为使用其突出显示的属性。如果它仍然无法正常工作,也有一个用于禁用该功能的字段,您需要检查一下。
关于iphone - 如何更改突出显示状态下的 UITableViewCell 文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7197746/