Commit adf6f1bf authored by Steven杜宇's avatar Steven杜宇

// 搜索按钮

parent 0bcb18c0
...@@ -58,7 +58,13 @@ class YHCertificateSearchViewController: YHBaseViewController { ...@@ -58,7 +58,13 @@ class YHCertificateSearchViewController: YHBaseViewController {
[weak self] text in [weak self] text in
guard let self = self else { return } guard let self = self else { return }
requestList(keyWord: text) requestList(keyWord: text)
}
bar.textChange = {
[weak self] text in
guard let self = self else { return }
if isEmptyString(text) {
requestList(keyWord: "")
}
} }
return bar return bar
}() }()
......
...@@ -73,10 +73,16 @@ class YHCertificateSearchBar: UIView { ...@@ -73,10 +73,16 @@ class YHCertificateSearchBar: UIView {
} }
} }
func setSearchButtonEnable(_ enable: Bool) {
searchBtn.isUserInteractionEnabled = enable
searchBtn.alpha = (enable ? 1.0 : 0.5)
}
func createUI() { func createUI() {
self.backgroundColor = .white self.backgroundColor = .white
setSearchButtonEnable(false)
contentView.addSubview(textField) contentView.addSubview(textField)
contentView.addSubview(searchBtn) contentView.addSubview(searchBtn)
self.addSubview(contentView) self.addSubview(contentView)
...@@ -99,6 +105,11 @@ class YHCertificateSearchBar: UIView { ...@@ -99,6 +105,11 @@ class YHCertificateSearchBar: UIView {
} }
@objc func textFieldChanged(textField:UITextField) { @objc func textFieldChanged(textField:UITextField) {
if isEmptyString(textField.text) {
setSearchButtonEnable(false)
} else {
setSearchButtonEnable(true)
}
if let textChange = textChange { if let textChange = textChange {
textChange(textField.text) textChange(textField.text)
} }
......
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