swift textfield 和 textview 实时获取 输入内容

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
    }

  

猜你喜欢

转载自www.cnblogs.com/qingzZ/p/9628101.html