textfield : func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { let fullStr = (textField.text! as NSString).replacingCharacters(in: range, with: string) delegate?.changeTextFieldText(tfTag: textField.tag, text: fullStr) return true }
textview : 一样
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { let fullStr = (textField.text! as NSString).replacingCharacters(in: range, with: string) return true }