How can I change UIButton title color? How can I change UIButton title color? ios ios

How can I change UIButton title color?


You can use -[UIButton setTitleColor:forState:] to do this.

Example:

Objective-C

[buttonName setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

Swift 2

buttonName.setTitleColor(UIColor.blackColor(), forState: .Normal)

Swift 3

buttonName.setTitleColor(UIColor.white, for: .normal)

Thanks to richardchildan


You created the UIButton is added the ViewController, The following instance method to change UIFont, tintColor and TextColor of the UIButton

Objective-C

 buttonName.titleLabel.font = [UIFont fontWithName:@"LuzSans-Book" size:15]; buttonName.tintColor = [UIColor purpleColor]; [buttonName setTitleColor:[UIColor purpleColor] forState:UIControlStateNormal];

Swift

buttonName.titleLabel.font = UIFont(name: "LuzSans-Book", size: 15)buttonName.tintColor = UIColor.purpleColor()buttonName.setTitleColor(UIColor.purpleColor(), forState: .Normal)

Swift3

buttonName.titleLabel?.font = UIFont(name: "LuzSans-Book", size: 15)buttonName.tintColor = UIColor.purplebuttonName.setTitleColor(UIColor.purple, for: .normal)


Solution in Swift 3:

button.setTitleColor(UIColor.red, for: .normal)

This will set the title color of button.