iOS UILabel

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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



Got any iOS Question?