---
title: textAlignment
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uilabel/textalignment
---

# textAlignment

The technique for aligning the text.

## Declaration

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

## Discussion

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 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 property. In iOS 9 and later, the default value of this property is NSTextAlignment.natural; prior to iOS 9, the default value was NSTextAlignment.left.

## See Also

### Accessing the text attributes

- [text](uikit/uilabel/text.md)
- [attributedText](uikit/uilabel/attributedtext.md)
- [font](uikit/uilabel/font.md)
- [textColor](uikit/uilabel/textcolor.md)
- [lineBreakMode](uikit/uilabel/linebreakmode.md)
- [lineBreakStrategy](uikit/uilabel/linebreakstrategy.md)
- [isEnabled](uikit/uilabel/isenabled.md)
- [enablesMarqueeWhenAncestorFocused](uikit/uilabel/enablesmarqueewhenancestorfocused.md)
- [showsExpansionTextWhenTruncated](uikit/uilabel/showsexpansiontextwhentruncated.md)
