Commit 93c7ec4d authored by David黄金龙's avatar David黄金龙
parents fa3e1fde bfcd2069
...@@ -12,6 +12,13 @@ enum YHNavLeftSecondBtnType: Int { ...@@ -12,6 +12,13 @@ enum YHNavLeftSecondBtnType: Int {
case none = 0 case none = 0
case search = 1 case search = 1
} }
enum YHNavRightBtnType: Int {
case none = 0
case clean = 1
}
class YHCustomNavigationBar: UIView { class YHCustomNavigationBar: UIView {
static let searchLeftIcon = "" static let searchLeftIcon = ""
...@@ -23,6 +30,7 @@ class YHCustomNavigationBar: UIView { ...@@ -23,6 +30,7 @@ class YHCustomNavigationBar: UIView {
} }
var backBlock:(()->())? var backBlock:(()->())?
var leftSecondBtnClick:(()->())? var leftSecondBtnClick:(()->())?
var rightBtnClick:(()->())?
private lazy var titleLabel: UILabel = { private lazy var titleLabel: UILabel = {
let label = UILabel() let label = UILabel()
...@@ -33,7 +41,7 @@ class YHCustomNavigationBar: UIView { ...@@ -33,7 +41,7 @@ class YHCustomNavigationBar: UIView {
return label return label
}() }()
private lazy var backButton: UIButton = { lazy var backButton: UIButton = {
let btn = UIButton() let btn = UIButton()
btn.setImage(UIImage(named: "nav_back_icon"), for: .normal) btn.setImage(UIImage(named: "nav_back_icon"), for: .normal)
btn.addTarget(self, action: #selector(didBackBtnClicked), for: .touchUpInside) btn.addTarget(self, action: #selector(didBackBtnClicked), for: .touchUpInside)
...@@ -46,6 +54,12 @@ class YHCustomNavigationBar: UIView { ...@@ -46,6 +54,12 @@ class YHCustomNavigationBar: UIView {
return btn return btn
}() }()
private lazy var rightButton: UIButton = {
let btn = UIButton()
btn.addTarget(self, action: #selector(didRightButtonClicked), for: .touchUpInside)
return btn
}()
static func navBar()-> YHCustomNavigationBar { static func navBar()-> YHCustomNavigationBar {
let bar = YHCustomNavigationBar(frame:CGRect(x: 0, y: 0, width: KScreenWidth, height: k_Height_NavContentBar)) let bar = YHCustomNavigationBar(frame:CGRect(x: 0, y: 0, width: KScreenWidth, height: k_Height_NavContentBar))
return bar return bar
...@@ -66,10 +80,17 @@ class YHCustomNavigationBar: UIView { ...@@ -66,10 +80,17 @@ class YHCustomNavigationBar: UIView {
} }
} }
func showRightButtonType(_ type: YHNavRightBtnType) {
if type == .clean {
rightButton.setImage(UIImage(named: "msg_clean"), for: .normal)
}
}
func createUI() { func createUI() {
self.addSubview(titleLabel) self.addSubview(titleLabel)
self.addSubview(backButton) self.addSubview(backButton)
self.addSubview(leftSecondButton) self.addSubview(leftSecondButton)
self.addSubview(rightButton)
titleLabel.snp.makeConstraints { make in titleLabel.snp.makeConstraints { make in
make.edges.equalToSuperview() make.edges.equalToSuperview()
...@@ -86,6 +107,12 @@ class YHCustomNavigationBar: UIView { ...@@ -86,6 +107,12 @@ class YHCustomNavigationBar: UIView {
make.centerY.equalToSuperview() make.centerY.equalToSuperview()
make.left.equalTo(backButton.snp.right).offset(5) make.left.equalTo(backButton.snp.right).offset(5)
} }
rightButton.snp.makeConstraints { make in
make.width.height.equalTo(24)
make.centerY.equalToSuperview()
make.right.equalToSuperview().offset(-20)
}
} }
} }
...@@ -101,4 +128,10 @@ extension YHCustomNavigationBar { ...@@ -101,4 +128,10 @@ extension YHCustomNavigationBar {
leftSecondBtnClick() leftSecondBtnClick()
} }
} }
@objc func didRightButtonClicked() {
if let rightBtnClick = rightBtnClick {
rightBtnClick()
}
}
} }
...@@ -26,26 +26,49 @@ class YHMsgViewController: YHBaseViewController { ...@@ -26,26 +26,49 @@ class YHMsgViewController: YHBaseViewController {
return tableView return tableView
}() }()
// lazy var navBar:UIView = { lazy var navBar: YHCustomNavigationBar = {
// let bar = UIView(frame: CGRect(x: 0, y: k_Height_StatusBar, width: KScreenWidth, height: k_Height_NavContentBar)) let bar = YHCustomNavigationBar.navBar()
// bar.backButton.isHidden = true
// return bar bar.backgroundColor = .white
// }() bar.title = "消息"
bar.showRightButtonType(.clean)
bar.backBlock = {
[weak self] in
guard let self = self else { return }
self.navigationController?.popViewController(animated: true)
}
bar.rightBtnClick = {
[weak self] in
guard let self = self else { return }
}
return bar
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
setupUI() setupUI()
} }
func setupUI() { func setupUI() {
gk_backStyle = .white
gk_navTitle = "消息" gk_navigationBar.isHidden = true
view.backgroundColor = .white
view.addSubview(navBar)
view.addSubview(tableView) view.addSubview(tableView)
navBar.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_statusBar())
make.height.equalTo(k_Height_NavContentBar)
}
tableView.snp.makeConstraints { make in tableView.snp.makeConstraints { make in
make.left.right.equalToSuperview() make.left.right.equalToSuperview()
make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar) make.top.equalToSuperview().offset(k_Height_NavigationtBarAndStatuBar)
make.bottom.equalToSuperview().offset(-k_Height_TabBar) make.bottom.equalToSuperview().offset(-k_Height_TabBar)
} }
} }
@objc func clean() {
}
} }
extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource { extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource {
...@@ -57,7 +80,6 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource { ...@@ -57,7 +80,6 @@ extension YHMsgViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: YHMessageSessionCell.cellReuseIdentifier, for: indexPath) as! YHMessageSessionCell let cell = tableView.dequeueReusableCell(withIdentifier: YHMessageSessionCell.cellReuseIdentifier, for: indexPath) as! YHMessageSessionCell
cell.backgroundColor = .red
return cell return cell
} }
......
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Group 2033194487@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "Group 2033194487@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
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