Swift UITextField限制输入字数

2021-12-22  本文已影响0人  分享学习
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        if range.length == 1 && string.count == 0 {
            return true
        }else if textField.text!.count >= 12 {
            return false
        }
        return true
    }
上一篇 下一篇

猜你喜欢

热点阅读