I am required to change the text color of the UILabel
which is contained in the UITableViewCell
on a button click. I have created a UIColor object
, which is set to specified color on the button click and called the UITableView reloadData
method, even then the color is not changing. How should I implement this?
I assume that you want to change the color of all rows in your table. (If you just want to change a single row, you will need its indexPath
).
Create a BOOL
variable that keeps track of the color state. In your button click routine, set this value appropriately and do a [tableView reloadData]
.
In cellForRowAtIndexPath
you need to check the variable and set the color for both states each time. It is essential that you do it both ways, otherwise the state of the cell will be unpredictable when scrolling.