iOS UITextField Set Alignment

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9

Example

Swift

textField.textAlignment = .Center 

Objective-C

[textField setTextAlignment: NSTextAlignmentCenter];

In the example, we have set the NSTextAlignment to center. You can also set to .Left, .Right, .Justified and .Natural.

.Natural is the default alignment for the current localization. That means for left-to-right languages (eg. English), the alignment is .Left; for right-to-left languages, it is .Right.



Got any iOS Question?