UITextField光标
2021-09-09 本文已影响0人
演繹陌路人生
- 开始编辑时将光标移动到最后
func textFieldDidBeginEditing(_ textField: UITextField) {
textField.tintColor = .clear
CATransaction.begin()
CATransaction.setCompletionBlock {
textField.selectedTextRange = textField.textRange(from: textField.endOfDocument, to: textField.endOfDocument)
textField.tintColor = nil
}
CATransaction.commit()
}