Instance Property

titleLabel

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

Declaration

@property(nonatomic, readonly, strong) UILabel *titleLabel;

Discussion

Although this property is read-only, its own properties are read/write. Use these properties primarily to configure the text of the button. For example:

UIButton *button                  = [UIButton buttonWithType: UIButtonTypeSystem];
button.titleLabel.font            = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode   = NSLineBreakByTruncatingTail;

Do not use the label object to set the text color or the shadow color. Instead, use the setTitleColor:forState: and setTitleShadowColor:forState: methods of this class to make those changes. To set the actual text of the label, use setTitle:forState: (button.titleLabel.text does not let you set the text).

The titleLabel property returns a value even if the button has not been displayed yet. The value of the property is nil for system buttons.

See Also

Configuring the Button Title

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

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