iPhone how to: center and horizontal align the contents of a UITextField


It’s as simple as:

1
2
theTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
theTextField.textAlignment = UITextAlignmentCenter;

Basically this will ensure that no matter how tall your text field is the actual text will be centered both vertically and horizontally.

Cheers…

, ,

  1. No comments yet.
(will not be published)