Changing UIButton text Changing UIButton text ios ios

Changing UIButton text


When laying out its subviews, a UIButton will set its titleLabel's text value using its own title values, so that you can set up to four different strings for the four states (normal, highlighted, selected, disabled).

Because of this feature, setting the titleLabel's text directly won't persist, and will be reset by the button when it lays out its subviews.

This is what you have to do to change the title text for a button's state.

[calibrationButton setTitle:@"Calibration" forState:UIControlStateNormal];


To set button text use the following method:

[calibrationButton setTitle: @"Calibration" forState: UIControlStateNormal];

See UIButton class reference for more details... http://developer.apple.com/library/ios/#documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html

Or in Swift 3:

calibrationButton.setTitle("Calibration", for: .normal)


programmatically you can set button title like below:

[myButton setTitle:@"buttonTitle" forState:UIControlStateNormal];

you can also set button title property from storyboard.