

In this example, we will add a label to the ViewController using the interface builder, and customize the label appearance at runtime by creating the label outlet in the ViewController class. This value can be accessed using the shadowOffset property at runtime. This property maintains the shadow offset. This value can be accessed at runtime by using shadowColor property. However, we can mention the shadow color which rendered beneath the text of the label. The default value of this attribute is transparent, which means no shadow appears beneath the text. The color is applied to the text in the label when the highlighted attribute is checked. We can choose the minimum font scale and set the value to allow the label to reduce the font size to fit the text. It can be set to either a minimum font scale or maximum font size.

This attribute is used to alter the font size of the label content before resorting to the truncation. This property can be accessed using lineBreakMode property on the label object. It can be set to word wrap or character wrap to break the content into multiple lines by words or by characters. It specifies the behavior of the label when the content is too big to adjust within the label bounds. This value can be accessed by using the baselineAdjustment property. It is a spacing attribute that controls the vertical alignment of the label when autoshrink is enabled. These values can be accessed at runtime by using isEnabled and isHighlighted property, respectively. The Enabled and highlighted control the appearance of the label. This attribute is used to control the behavior of the label. This value can be accessed at runtime by using numberOfLines property on the label object. We can set it to 0 to make the label to render the unlimited lines. It represents the maximum number of lines the label uses to render the content. In plain mode, the alignment is set for the whole label content whereas, in attributed mode, we can maintain the specific alignment for the specific paragraph of the label.

We can place the label content, left align, center, right-align, justified, or natural within the frame. It is used to set the alignment of the label content within the frame. In the custom font, we can set the font family and style of the label content. We can define the system or custom font to the label. It includes the font family, size, and the opacity of the content. This is used to alter the font of the label content. In plain mode, the color is set for the whole content, whereas, in attributed mode, we can define the color for a particular part of the content. It is used to set the font color of the label.

This value can be accessed at runtime with the text and attributedText properties. In attributed mode, we can use the More menu to reveal additional appearance attributes. Plain mode displays the label's content with the uniform appearance, whereas the attributed mode applies styling attributes within the string. To define the appearance of the label, we can assign two modes to the label i.e., Plain mode and attributed mode. This attribute can be given to set the content of the label. Interface Builder Attributes for UILabel SN Set up auto-layout rules to define the size and position of the label in your interface.Configure the appearance of the label using the attribute inspector.Search for the label in the Object library and drag the result to the storyboard or create an object of UILabel class in the ViewController class.The following steps are used to add the label to the interface. We can add the labels to the interface programmatically or by using a storyboard. The label can show attributed strings, as well. We can customize the substrings within the label. The appearance of the Label can be configured.
