How to set padding for UITextField in Swift — the easiest way

Of course you also need add a top and a bottom paddings, but this can be achieved through autolayout height size of the textfield.

Result: left padding for UITextField placeholder and text
import UIKit
class ViewController: UIViewController {

@IBOutlet weak var myTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
let paddingView = UIView(frame: CGRectMake(0, 0, 15, self.myTextField.frame.height))
myTextField.leftView = paddingView
myTextField.leftViewMode = UITextFieldViewMode.Always
}
}

We used this technique in our new app Taskler (to-do list for iPhone), but without big indent.

UITextField in Taskler