To fix the issue I subclassed UITextField
, and added the following to the subclass:
class CustomTextField: UITextField {
override func editingRectForBounds(bounds: CGRect) -> CGRect {
let padding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
return UIEdgeInsetsInsetRect(bounds, padding)
}
}
Swift 4.2 & Xcode 10
class CustomTextField: UITextField {
override func editingRect(forBounds bounds: CGRect) -> CGRect {
let padding = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 5)
return bounds.inset(by: padding)
}
}
Answer was found here: Create space at the beginning of a UITextField