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