When deleting a character from UITextField, the cursor does not stay in the same place, but moves to the end of the line
+38 (gray) is a mask that is added as soon as the user begins to enter a number
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { if textField == self.textField { let returnKey = (string as NSString).length == 0 let oldLength = textField.text!.length let replacementLength = string.length let rangeLength = range.length let newLength = oldLength - rangeLength + replacementLength return newLength <= 18 || returnKey } return true } } 
shouldChangeCharactersIn- Max Mikheyenko