I need to restrict to UITextField text cursor should only focus on end of text every time. Ex- if user entered OTP in textField and again he want to replace digit from text field when he tap to UITextField then cursor should focus on end of text only not beginning of text. I added below code
func textFieldDidBeginEditing(_ textField: UITextField){
DispatchQueue.main.async{
let position = textField.endOfDocument textField.selectedTextRange = textField.textRange(from: position, to: position)
}
}
It is working On first time textfield selection. After once cursor focussed in UITextField that time it is moving to Start position if user tap on start position.