<!--
{
  "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/textAlignment",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UILabel(py)textAlignment"
  },
  "title" : "textAlignment"
}
-->

# textAlignment

The technique for aligning the text.

```
var textAlignment: NSTextAlignment { get set }
```

## Discussion

If you’re using styled text, assigning a new value to this property applies the text alignment to the entirety of the string in the [`attributedText`](/documentation/UIKit/UILabel/attributedText) property. If you want to apply the alignment to only a portion of the text, create a new attributed string with the desired style information and associate it with the label. If you aren’t using styled text, this property applies to the entire text string in the [`text`](/documentation/UIKit/UILabel/text) property.

In iOS 9 and later, the default value of this property is [`NSTextAlignment.natural`](/documentation/UIKit/NSTextAlignment/natural); prior to iOS 9, the default value was [`NSTextAlignment.left`](/documentation/UIKit/NSTextAlignment/left).

---

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)