functextViewDidChange(_textView:UITextView) {
iftextView.text.count >200{
//获得已输出字数与正输入字母数
letselectRange = textView.markedTextRange;
//获取高亮部分 - 如果有联想词则解包成功
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);
}