<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UILabel",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UILabel"
  },
  "title" : "UILabel"
}
-->

# UILabel

A view that displays one or more lines of informational text.

```
@MainActor class UILabel
```

## Overview

You can configure the overall appearance of a label’s text, and use attributed strings to customize the appearance of substrings within the text. Add and customize labels in your interface programmatically, or with the Attributes inspector in Interface Builder.

Follow these steps to add a label to your interface:

- Supply either a string or an attributed string that represents the content.
- If you’re using a nonattributed string, configure the appearance of the label.
- Set up Auto Layout rules to govern the size and position of the label in your interface.
- Provide accessibility information and localized strings.

### Customize the label’s appearance

You provide the content for a label by assigning either a <doc://com.apple.documentation/documentation/Foundation/NSString> object to the [`text`](/documentation/UIKit/UILabel/text) property, or an <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> object to the [`attributedText`](/documentation/UIKit/UILabel/attributedText) property. The label displays the property set most recently.

The [`attributedText`](/documentation/UIKit/UILabel/attributedText) property allows you to control the appearance of individual characters and groups of characters, using the <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> API. The following image shows a label displaying an <doc://com.apple.documentation/documentation/Foundation/NSAttributedString> that includes attributes to customize the font, color, and alignment of the string.

![A screenshot of a label showing text aligned to the left and formatted with different attributes. The first attribute changes the text color of the second word to a color different from the rest of the text. The second attribute applies a bold font to the fifth word. The third and final attribute highlights the last four words that the label displays. The display text ends with an ellipsis indicating that the label truncates the full text at the end due to its line break mode. ](images/com.apple.uikit/media-2759882@2x.png)

If you want to format the label’s text in a uniform fashion, set the [`text`](/documentation/UIKit/UILabel/text) property to an <doc://com.apple.documentation/documentation/Foundation/NSString> object containing the content, and configure the [`font`](/documentation/UIKit/UILabel/font), [`textColor`](/documentation/UIKit/UILabel/textColor), [`textAlignment`](/documentation/UIKit/UILabel/textAlignment), and [`lineBreakMode`](/documentation/UIKit/UILabel/lineBreakMode) properties. The following image shows a label displaying an <doc://com.apple.documentation/documentation/Foundation/NSString> with a custom font, color, and alignment.

![A screenshot of a label displaying text with a center alignment and truncated in the middle, showing the beginning and ending of the full text, separated with an ellipsis.](images/com.apple.uikit/media-2759883@2x.png)

If you set these appearance properties on a label that displays the content of the [`attributedText`](/documentation/UIKit/UILabel/attributedText) property, the label overrides the appropriate attributes and displays the attributed string with a uniform appearance. The following image shows the label from the first image with the [`textColor`](/documentation/UIKit/UILabel/textColor) property set to green.

![A screenshot of a label showing left aligned text. The color of the text is green.](images/com.apple.uikit/media-2759884@2x.png)

Specify the maximum number of lines for the label to use when laying out the text with the [`numberOfLines`](/documentation/UIKit/UILabel/numberOfLines) property. Setting a value of `0` allows the label to use as many lines as necessary to lay out the text within the label’s width. Use the [`lineBreakMode`](/documentation/UIKit/UILabel/lineBreakMode) property to control how the label splits the text into multiple lines, and the truncation behavior associated with the final line.

Use Auto Layout to position and optionally size the label. The intrinsic content size for a label defaults to the size that displays the entirety of the content on a single line. If you provide Auto Layout constraints that define the width of the label but not the height, the label’s intrinsic content size adjusts the height to display the text completely.

When the label has its size completely defined externally, you can specify how it handles the situation when its content doesn’t fit within the bounds. To reduce the font size, set the [`adjustsFontSizeToFitWidth`](/documentation/UIKit/UILabel/adjustsFontSizeToFitWidth) property to <doc://com.apple.documentation/documentation/Swift/true> and set the [`minimumScaleFactor`](/documentation/UIKit/UILabel/minimumScaleFactor) property to a value between `0` and `1`. The latter of these properties represents how much smaller than the requested font size the label scales the text. Setting the [`allowsDefaultTighteningForTruncation`](/documentation/UIKit/UILabel/allowsDefaultTighteningForTruncation) property to <doc://com.apple.documentation/documentation/Swift/true> instructs the label to reduce the spacing between characters before truncating the string. The following image shows a label that uses [`minimumScaleFactor`](/documentation/UIKit/UILabel/minimumScaleFactor) and [`adjustsFontSizeToFitWidth`](/documentation/UIKit/UILabel/adjustsFontSizeToFitWidth) to display the content of an entire string that would otherwise have overflowed.

![A screenshot showing two labels containing the same text, displayed side by side. The label on the left side truncates the text at the end. The label on the right side displays the full text in an adjusted, smaller font that fits within the display area of the label.](images/com.apple.uikit/media-2759885@2x.png)

### Design labels for a wide audience

Labels provide valuable information to your users. To make sure that information reaches a wide audience, internationalize text and support accessibility in your labels. For information about how to implement internationalization and localization, see [Internationalization](https://developer.apple.com/internationalization/). Labels are accessible to VoiceOver by default. The default accessibility traits for a label are Static Text and User Interaction Enabled. For more information, see [Supporting VoiceOver in your app](/documentation/UIKit/supporting-voiceover-in-your-app). To learn about using text styles to support Dynamic Type, see [Scaling fonts automatically](/documentation/UIKit/scaling-fonts-automatically).

For design guidance, see [Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/components/layout-and-organization/labels/).

## Topics

### Accessing the text attributes

[`text`](/documentation/UIKit/UILabel/text)

The text that the label displays.

[`attributedText`](/documentation/UIKit/UILabel/attributedText)

The styled text that the label displays.

[`font`](/documentation/UIKit/UILabel/font)

The font of the text.

[`textColor`](/documentation/UIKit/UILabel/textColor)

The color of the text.

[`textAlignment`](/documentation/UIKit/UILabel/textAlignment)

The technique for aligning the text.

[`lineBreakMode`](/documentation/UIKit/UILabel/lineBreakMode)

The technique for wrapping and truncating the label’s text.

[`lineBreakStrategy`](/documentation/UIKit/UILabel/lineBreakStrategy)

The strategy that the system uses to break lines when laying out multiple lines of text.

[`isEnabled`](/documentation/UIKit/UILabel/isEnabled)

A Boolean value that determines whether the label draws its text in an enabled state.

[`enablesMarqueeWhenAncestorFocused`](/documentation/UIKit/UILabel/enablesMarqueeWhenAncestorFocused)

A Boolean value that determines whether the label scrolls its text while one of its containing views has focus.

[`showsExpansionTextWhenTruncated`](/documentation/UIKit/UILabel/showsExpansionTextWhenTruncated)

A Boolean value that determines whether the full text of the label displays when the pointer hovers over the truncated text.

### Sizing the label’s text

[`adjustsFontSizeToFitWidth`](/documentation/UIKit/UILabel/adjustsFontSizeToFitWidth)

A Boolean value that determines whether the label reduces the text’s font size to fit the title string into the label’s bounding rectangle.

[`allowsDefaultTighteningForTruncation`](/documentation/UIKit/UILabel/allowsDefaultTighteningForTruncation)

A Boolean value that determines whether the label tightens text before truncating.

[`baselineAdjustment`](/documentation/UIKit/UILabel/baselineAdjustment)

An option that controls whether the text’s baseline remains fixed when text needs to shrink to fit in the label.

[`minimumScaleFactor`](/documentation/UIKit/UILabel/minimumScaleFactor)

The minimum scale factor for the label’s text.

[`numberOfLines`](/documentation/UIKit/UILabel/numberOfLines)

The maximum number of lines for rendering text.

[`sizingRule`](/documentation/UIKit/UILetterformAwareAdjusting/sizingRule)

The typographic bounds-sizing behavior that handles text with fonts that contain oversize characters.

[`adjustsLetterSpacingToFitWidth`](/documentation/UIKit/UILabel/adjustsLetterSpacingToFitWidth)

A Boolean value that indicates whether the label adjusts spacing between letters to fit the string within the label’s bounds rectangle.

[`minimumFontSize`](/documentation/UIKit/UILabel/minimumFontSize)

The size of the smallest permissible font when drawing the label’s text.

### Managing highlight values

[`highlightedTextColor`](/documentation/UIKit/UILabel/highlightedTextColor)

The highlight color for the label’s text.

[`isHighlighted`](/documentation/UIKit/UILabel/isHighlighted)

A Boolean value that determines whether the label draws its text with a highlight.

### Managing vibrancy

[`preferredVibrancy`](/documentation/UIKit/UILabel/preferredVibrancy)

[`UILabelVibrancy`](/documentation/UIKit/UILabelVibrancy)

### Drawing a shadow

[`shadowColor`](/documentation/UIKit/UILabel/shadowColor)

The shadow color of the text.

[`shadowOffset`](/documentation/UIKit/UILabel/shadowOffset)

The shadow offset, in points, for the text.

### Drawing and positioning overrides

[`textRect(forBounds:limitedToNumberOfLines:)`](/documentation/UIKit/UILabel/textRect(forBounds:limitedToNumberOfLines:))

Returns the drawing rectangle for the label’s text.

[`drawText(in:)`](/documentation/UIKit/UILabel/drawText(in:))

Draws the label’s text, or its shadow, in the specified rectangle.

### Getting the layout constraints

[`preferredMaxLayoutWidth`](/documentation/UIKit/UILabel/preferredMaxLayoutWidth)

The preferred maximum width, in points, for a multiline label.

### Accessing additional attributes

[`isUserInteractionEnabled`](/documentation/UIKit/UILabel/isUserInteractionEnabled)

A Boolean value that determines whether the system ignores and removes user events for this label from the event queue.

[clipsToBounds](/documentation/UIKit/UILabel-clipsToBounds)

A Boolean value that determines whether subviews are confined to the bounds of the view.

### Supporting types

[`NSTextAlignment`](/documentation/UIKit/NSTextAlignment)

Constants that specify text alignment.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)