Contents

titleLabel

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

Declaration

var titleLabel: UILabel? { get }

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(_:for:) and setTitleShadowColor(_:for:) methods of this class to make those changes. To set the actual text of the label, use setTitle(_:for:) (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

Related Documentation

Managing the title