Is there a way to move the cursor of TextField to the end of the text when editing?- SwiftUI
I have created a textfield in Swift UI and I'm looking for a way to make the cursor of the textfield on editing to be at the end of the text even if I tapped the first letter on the textfield.
I think you mean something like this, to set .endOfDocument
:
let endPosition = textField.endOfDocument
textField.selectedTextRange = textField.textRange(from: endPosition, to: endPosition)
Now it will stay at the end of the position. If you search something more advanced, I recommend you this post and its answer.