Instance Method

setTitle:forState:

Sets the title to use for the specified state.

Declaration

- (void)setTitle:(NSString *)title forState:(UIControlState)state;

Parameters

title

The title to use for the specified state.

state

The state that uses the specified title. The possible values are described in UIControlState.

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, 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.

- attributedTitleForState:

Returns the styled title associated with the specified state.

- setAttributedTitle:forState:

Sets the styled title to use for 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.