I have a custom font in a UITextField, and I\'ve noticed that when it\'s accessed (when the keyboard appears), the text shifts down by a very small amount -- maybe
This is expected behaviour in a standard UITextField. You can however solve this by subclassing UITextField and by adjusting the bounds for the text itself.
Swift 3
override func textRect(forBounds bounds: CGRect) -> CGRect {
return(bounds.insetBy(dx: 0, dy: 0))
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
return(bounds.insetBy(dx: 0, dy: -0.5))
}
override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
return(bounds.insetBy(dx: 0, dy: 0))
}
This should do the trick!