setTitle(_:for:)
Sets the title to use for the specified state.
Declaration
func setTitle(_ title: String?, for state: UIControl.State)Parameters
- title:
The title to use for the specified state.
- state:
The state that uses the specified title. State Swift.struct describes the possible values.
Discussion
Use this method to set the title for the button. The title you specify derives its formatting from the button’s associated label object. If you set both a title and an attributed title for the button, the button prefers the use of the attributed title over this one.
At a minimum, set the value for the normal state. If you don’t specify a title for the other states, the button uses the title associated with the normal state. If you don’t set the value for normal, then the property defaults to a system value.