Instance Method

setAttributedTitle:forState:

Sets the styled title to use for the specified state.

Declaration

- (void)setAttributedTitle:(NSAttributedString *)title forState:(UIControlState)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 UIControlState.

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 UIControlStateNormal state. If the value for UIControlStateNormal is not set, then the property defaults to a system value.

See Also

Configuring the Button Title

titleLabel

A view that displays the value of the currentTitle property for a button.

- titleForState:

Returns the title associated with the specified state.

- setTitle:forState:

Sets the title to use for the specified state.

- attributedTitleForState:

Returns the styled title associated with the specified state.

- titleColorForState:

Returns the title color used for a state.

- setTitleColor:forState:

Sets the color of the title to use for the specified state.

- titleShadowColorForState:

Returns the shadow color of the title used for a state.

- setTitleShadowColor:forState:

Sets the color of the title shadow to use for the specified state.

reversesTitleShadowWhenHighlighted

A Boolean value that determines whether the title shadow changes when the button is highlighted.