setAttributedTitle(_:for:)
Sets the styled title to use for the specified state.
Declaration
func setAttributedTitle(_ title: NSAttributedString?, for state: UIControl.State)Parameters
- title:
The styled text string so use for the title.
- state:
The state that uses the specified title. The possible values are described in State Swift.struct.
Discussion
Use this method to set the title of the button, including any relevant formatting information. If you set both a title and an attributed title for the button, the button prefers the use of the attributed title.
At a minimum, you should set the value for the normal state. If a title is not specified for a state, the default behavior is to use the title associated with the normal state. If the value for normal is not set, then the property defaults to a system value.