functextViewDidChange(_textView:UITextView) {
? ? ? ? iftextView.text.count >200{
? ? ? ? ? ? //獲得已輸出字?jǐn)?shù)與正輸入字母數(shù)
? ? ? ? ? ? letselectRange = textView.markedTextRange;
? ? ? ? ? ? //獲取高亮部分 - 如果有聯(lián)想詞則解包成功
? ? ? ? ? ? ifletselectRange = selectRange {
? ? ? ? ? ? ? ? letposition =? textView.position(from: (selectRange.start), offset:0);
? ? ? ? ? ? ? ? if(position !=nil) {
? ? ? ? ? ? ? ? ? ? return
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? lettextContent = textView.text;
? ? ? ? ? ? lettextNum = textContent?.count;
? ? ? ? ? ? //截取200個字
? ? ? ? ? ? iftextNum! >200{
? ? ? ? ? ? ? ? letindex = textContent?.index((textContent?.startIndex)!, offsetBy:200);
? ? ? ? ? ? ? ? letstr =? String(textContent![..
? ? ? ? ? ? ? ? textView.text = str;
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? letcount = textView.text.count;
? ? ? ? self.m_countLabel?.text =String.init(format:"%d/200", count);
? ? }