Search code examples
swiftautolayoutuitextfieldprogrammatically-created

How to set a distance between placeHolder / user text and left border in UITextField


I have a design project, where the distance between placeholder and the left border is 16. That is like it should be:

but I can't find a property to set it on 16 points, as a result I have this: But now it is like this:

I do my UI programmatically, but it is first time, when I can't do this for a week)))

I tried to write properties like these:


Solution

  • Try this:

    textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 16, height: 62))
    textField.leftViewMode = .always