UITextField光标

  1. 开始编辑时将光标移动到最后
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()
    }

你可能感兴趣的:(UITextField光标)