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

# textAlignment

The technique for aligning the text.

## Declaration

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

## Discussion

Discussion This property applies to the both the main text string and the placeholder string. The default value of this property is NSLeftTextAlignment. If you are using styled text, assigning a new value to this property causes the text alignment to be applied to the entire 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 text field.

## See Also

### Configuring the text attributes

- [text](uikit/uitextfield/text.md)
- [attributedText](uikit/uitextfield/attributedtext.md)
- [placeholder](uikit/uitextfield/placeholder.md)
- [attributedPlaceholder](uikit/uitextfield/attributedplaceholder.md)
- [defaultTextAttributes](uikit/uitextfield/defaulttextattributes.md)
- [font](uikit/uitextfield/font.md)
- [textColor](uikit/uitextfield/textcolor.md)
- [typingAttributes](uikit/uitextfield/typingattributes.md)
- [UITextField.BorderStyle](uikit/uitextfield/borderstyle-swift.enum.md)
