I have custom UITableViewCell
. UITableViewCell
have one UILabel
and one UIButton
. I want when click button then text of label change color to "redColor". I don't process???
Inside your custom table view cell set touch up inside event for the button like this
[self.button addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside];
In the same class add the following method
-(IBAction) clicked:(id)sender {
[self.label setTextColor:[UIColor redColor]];
}
one thing you can do is maintain an array whose each element represents the corresponding row number.
Initialize the array with 0 means all the label will have text color black.
Now set the index of each button equal to index path.row in cell for row method .
Now when the button is clicked set the value in array at index button.tag to 1 and others to 0 and reload tableview.
Now in cell for row check if items in the array at index indexpath.row ==1 then set the color of uilabel to red else black.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.