The UILabel class implements a read-only text view in iOS. 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.
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.
The default content mode of the UILabel class is UIViewContentModeRedraw
. This mode causes the view to redraw its contents every time its bounding rectangle changes. You can change this mode by modifying the inherited contentMode
property of the class.
New label objects are configured to disregard user events and clip subviews by default. If you want to handle events in a custom subclass of UILabel
, you must explicitly change the value of the userInteractionEnabled
property to YES after initializing the object. If you want to allow subviews to extend beyond the bounds of a label, you must explicitly change the value of the label’s clipsToBounds
property to NO.
For information about basic view behaviors, see View Programming Guide for iOS.
For more information about appearance and behavior configuration, see Labels in UIKit User Interface Catalog.