Vertically aligning middle with Swift:
In viewDidLoad:
textField.addObserver(self, forKeyPath: "contentSize", options: NSKeyValueObservingOptions.New, context: nil)
Then somewhere else in your view controller:
override func observeValueForKeyPath(keyPath: String, ofObject object: AnyObject, change: [NSObject : AnyObject], context: UnsafeMutablePointer) {
var topCorrect : CGFloat = (textField.frame.height - textField.contentSize.height);
topCorrect = topCorrect < 0.0 ? 0.0 : topCorrect / 2
textField.contentOffset = CGPoint(x: 0, y: -topCorrect)
}
where textField is wired up to the actual text field in your view.