Unfortunately, none of the answers worked for me.
Answer to
@blackjacx worked, but only sometimes :(
I started debugging, and here is what I found:
1 - The real problem seems to be related to the closed UITextField subtitle of type UIFieldEditorContentView

Below you can see that the y this subview does not match the UITextField itself:

Realizing this, I came up with the following workaround:
override func layoutSubviews() { super.layoutSubviews() fixMisplacedEditorContentView() } func fixMisplacedEditorContentView() { if #available(iOS 10, *) { for view in subviews { if view.bounds.origin.y < 0 { view.bounds.origin = CGPoint(x: view.bounds.origin.x, y: 0) } } } }
You will need to subclass UITextField and override layoutSubviews to add the ability to manually set the 0 y any subhead set to a negative value. Since this problem does not occur with iOS 9 below, I added a check to make a workaround only when it is on iOS 10.
The result you can see below:

2 - This workaround does not work if the user selects a text submenu (selectAll works fine)
Since text selection is not required for my application, I would rather disable it. For this you can use the following code (Swift 3):
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { if #available(iOS 10, *) { if action == #selector(UIResponderStandardEditActions.select(_:)) { return false } } return super.canPerformAction(action, withSender: sender) }
Filipe Alvarenga Apr 13 '17 at 19:29 2017-04-13 19:29
source share