123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //
- // MCNavBarSearchView.swift
- // HCQuanfangtong
- //
- // Created by Apple on 2022/8/1.
- // Copyright © 2022 Jyp. All rights reserved.
- //
- import UIKit
- import RxSwift
- import RxCocoa
- class MCNavBarSearchView: MCNavBarView {
-
- /// 初始化方法
- /// - Parameters:
- /// - placeholder: <#placeholder description#>
- /// - beginEditBlock: 开始编辑的方法
- /// - endEditBlock: 搜索的方法
- /// - tap: 点击事件
- /// - style: <#style description#>
- init(placeholder: String?, beginEditBlock: (()->Void)?, endEditBlock: ((String?)->Void)?, tap: (()->Void)? = nil, style: MCNavBarStyle? = nil){
- super.init(title: nil, subTitle: nil, style: style)
- self.searchBar = QFTSearchBar.init(frame: CGRect.zero)
- self.searchBar.contentend = endEditBlock
- self.searchBar.showKeyBoard = beginEditBlock
- if tap.isNotNil{
- self.searchBar.toSearch = {isClear in
- if isClear{
- endEditBlock?("")
- }
- else{
- tap?()
- }
- }
- }
-
- self.searchBar.placeholder = placeholder
- self.searchBar.layer.cornerRadius = self.navStyle.styleForSearchHeight * 0.5
- self.searchBar.setContentHuggingPriority(UILayoutPriority(rawValue: 240), for: .horizontal)
- self.contentView.addArrangedSubview(self.searchBar)
- self.searchBar.mas_makeConstraints { make in
- make?.height.offset()(self.navStyle.styleForSearchHeight)
- }
- self.resetConstraint()
-
- }
-
- override var type: MCNavBarType{
- .search
- }
-
- //MARK: - Private Property
- private var searchBar: QFTSearchBar!
-
- //MARK: - Override MCNavBarDelegate
- override func setNavTitle(_ title: String?) {
- self.searchBar.text = title
- }
- override func setNavSubTitle(_ title: String?) {
- self.searchBar.placeholder = title
- }
-
- //MARK: -
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
-
-
- }
|