文本框不能用textfield.text.count来计算字符 会造成文本框不能删除
functextField(_textField:UITextField, shouldChangeCharactersIn range:NSRange, replacementString string:String) ->Bool{
letproposeLength = (textField.text?.lengthOfBytes(using:String.Encoding.utf8))! - range.length+ string.lengthOfBytes(using:String.Encoding.utf8)
iftextField.tag==0{
if proposeLength >5{
setToast(str:"不能大于5个字")
returnfalse
}else{
returntrue
}
}
return true
}