UILabel

Download ios eBook

Introduction

The UILabel class implements a read-only text view. You can use this class to draw one or multiple lines of static text, such as those you might use to identify other parts of your user interface. The base UILabel class provides support for both simple and complex styling of the label text. You can also control over aspects of appearance, such as whether the label uses a shadow or draws with a highlight. If needed, you can customize the appearance of your text further by subclassing.

Syntax

  • UILabel.numberOfLines: Int // get or set the maximum number of lines the label can have. 0 is unlimited
  • UILabel.text: String? // get or set the text the label displays
  • UILabel.textColor: UIColor! // get or set the color of the text on the label
  • UILabel.tintColor: UIColor! // get or set the tint color of the label
  • UILabel.attributedText: NSAttributedString? // get or set the attributed text of the label
  • UILabel.font: UIFont! // get or set the font of the text on the label
  • UILabel.textAlignment: NSTextAlignment // get or set the alignment of the text

Remarks

UILabels are views which can be used to display one or many lines of text. It contains multiple ways of stylizing text, such as shadows, text colors, and fonts.

UILabels can also display Attributed Strings, which is text + inline markup to apply styles to portions of the text.

UILabel does not conform to the UIAppearance protocol, so you cannot use UIAppearance proxy methods to customise appearance of UILabels. See this discussion for more.

Apple Developer reference here

Related Examples

Stats

5759 Contributors: 110
Thursday, August 3, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook