Hi i am creating a UIButton programatically and I am trying to change the text color of the button’s textLabel to orange. I’ve tried both lines below but they aren’t working. Can someone tell me how to do this properly.
[myButton.titleLabel setTextColor:[UIColor orangeColor]];
and,
myButton.titleLabel.textColor = [UIColor orangeColor];
Try using
- (void)setTitleColor:(UIColor *)color forState:(UIControlState)stateinstead:The problem here is that a UIButton’s titleLabel is read only, though its properties are not. That’s why your seemingly correct code doesn’t work.