2

选择时,我更改了 UITableViewCell 的背景颜色:

UIView *selectedBackgroundColor = [[UIView alloc] init];
[selectedBackgroundColor setBackgroundColor:[UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1]];
[cell setSelectedBackgroundView:selectedBackgroundColor];

但它仍然将 UITableViewCell 标签的颜色更改为白色,这是我不想要的。我可以默认阻止它这样做吗?

4

1 回答 1

4

您还需要设置highlightedTextColortextLabel 的属性:

cell.textLabel.highlightedTextColor=[UIColor colorWithRed:0.123 green:0.32163 blue:0.54647 alpha:1.0];//or whatever color you want

如果您不希望文本颜色在选中时发生变化,请将此颜色设置为textColor与 textlabel 的属性相同的颜色。

cell.textLabel.textColor=[UIColor colorWithRed:0.123 green:0.32163 blue:0.54647 alpha:1.0];
于 2013-05-01T23:57:00.577 回答