Commit 11c0ebc3 authored by pete谢兆麟's avatar pete谢兆麟

解决密码框问题

parent 32fb3293
...@@ -30,8 +30,8 @@ class YHSmsCodeInputView: UIView { ...@@ -30,8 +30,8 @@ class YHSmsCodeInputView: UIView {
var config: YHSmsCodeViewConfig = YHSmsCodeViewConfig() var config: YHSmsCodeViewConfig = YHSmsCodeViewConfig()
// 此输入框并不显示,只是接收输入 // 此输入框并不显示,只是接收输入
lazy var textField: UITextField = { lazy var textField: YHTextField = {
let textField = UITextField() let textField = YHTextField()
textField.backgroundColor = .clear textField.backgroundColor = .clear
textField.tintColor = .clear textField.tintColor = .clear
textField.textColor = .clear textField.textColor = .clear
...@@ -61,7 +61,6 @@ class YHSmsCodeInputView: UIView { ...@@ -61,7 +61,6 @@ class YHSmsCodeInputView: UIView {
textField.snp.makeConstraints { make in textField.snp.makeConstraints { make in
make.edges.equalTo(self) make.edges.equalTo(self)
} }
// textField.becomeFirstResponder()
// 输入框数量 // 输入框数量
let count = config.count let count = config.count
...@@ -178,4 +177,19 @@ extension YHSmsCodeInputView: UITextFieldDelegate { ...@@ -178,4 +177,19 @@ extension YHSmsCodeInputView: UITextFieldDelegate {
let textLength = text.charactersArray.count + string.charactersArray.count - range.length let textLength = text.charactersArray.count + string.charactersArray.count - range.length
return textLength <= config.count return textLength <= config.count
} }
}
class YHTextField: UITextField {
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return false
}
open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
if let ges = gestureRecognizer as? UITapGestureRecognizer {
return true
} else {
return false
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment