swift textField

public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
guard let textString = textField.text else {
return false
}
let textLeng: Int = textString.count
let replace: Int = string.count - range.length
return textLeng + replace <= maxTextCount
}

@objc func textFiledChanged(sender: UITextField) {
if let textString = sender.text {
describeLab.isHidden = textString.count > 0
}
}

你可能感兴趣的:(swift textField)