Changed selection color of UITableViewCell, but it still changes the UILabels font colors. How do I prevent this?

I changed the background color of UITableViewCell when selected with this:

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];

But it still changes the color of the UITableViewCell's labels to white, which I don't want. Can I stop it from doing this by default?


You need to set the highlightedTextColor property of the textLabel as well:

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

If you don't want the text color to change when selected, set this color to the same color as the textColor property of the textlabel.

cell.textLabel.textColor=[UIColor colorWithRed:0.123 green:0.32163 blue:0.54647 alpha:1.0];

Need Your Help

Default php debugger in XAMPP or Wamp

php debugging iis webmatrix

Is there any default debugger in XAMPP or Wamp or we need to insatll it manually. I earlier worked in WebMatrix and found that it didn't debug my PHP code correctly.

AssertEquals on sorted lists always returning false

java unit-testing junit

I am trying to write a unit test to test the sorting of two lists. What I have is I am calling the custom sorting comparator and then comparing the original list with the sorted list. Then from t...