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
    }

  

 

posted on 2018-09-11 15:41  懂事长qingzZ  阅读(2910)  评论(0编辑  收藏  举报