简体   繁体   中英

UILabel: change a text color when click button

I am beginner in iOS programming.

So, I want to change the text color when user click button.

My code:

- (IBAction)buttonGetText:(id)sender {
self.textChange.textColor = "red"; 
}

But it doesn't work. What do I need to do? Thank you everyone.

This:

self.textChange.textColor = "red"; 

Doesn't make sense, you need to use UIColor .

Try this:

self.textChange.textColor = [UIColor redColor]; 

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM