59 lines
1.9 KiB
Swift
59 lines
1.9 KiB
Swift
//
|
||
// MPPositive_BaseViewController.swift
|
||
// MusicPlayer
|
||
//
|
||
// Created by Mr.Zhou on 2024/4/18.
|
||
//
|
||
|
||
import UIKit
|
||
///b面基类控制器
|
||
class MPPositive_BaseViewController: MP_BaseViewController {
|
||
//导航栏标题
|
||
private lazy var navTitleLabel:UILabel = createLabel(font: .systemFont(ofSize: 20*width, weight: .regular), textColor: .white, textAlignment: .center)
|
||
//pop按钮
|
||
private lazy var popBtn:UIButton = {
|
||
let btn = UIButton()
|
||
btn.setBackgroundImage(UIImage(named: "Pop‘logo"), for: .normal)
|
||
btn.addTarget(self, action: #selector(popActionClick(_ :)), for: .touchUpInside)
|
||
return btn
|
||
}()
|
||
lazy var navView:UIView = setTitleView()
|
||
|
||
override func viewDidLoad() {
|
||
super.viewDidLoad()
|
||
view.addSubview(navView)
|
||
}
|
||
//设置顶部titleView
|
||
private func setTitleView() -> UIView {
|
||
let topView = UIView(frame: .init(x: 0, y: statusBarHeight, width: screen_Width, height: 50*width))
|
||
topView.backgroundColor = .clear
|
||
topView.addSubview(navTitleLabel)
|
||
navTitleLabel.snp.makeConstraints { make in
|
||
make.center.equalToSuperview()
|
||
}
|
||
return topView
|
||
}
|
||
///设置导航栏title
|
||
func setTitle(_ text:String) {
|
||
navTitleLabel.text = text
|
||
}
|
||
///设置导航栏popBtn
|
||
func setPopBtn() {
|
||
navView.addSubview(popBtn)
|
||
popBtn.snp.makeConstraints { make in
|
||
make.width.height.equalTo(42*width)
|
||
make.centerY.equalToSuperview()
|
||
make.left.equalTo(16*width)
|
||
}
|
||
}
|
||
override func viewDidLayoutSubviews() {
|
||
super.viewDidLayoutSubviews()
|
||
//当页面布局完成后,将navView移动至最上层
|
||
view.bringSubviewToFront(navView)
|
||
}
|
||
//pop上一个页面
|
||
@objc private func popActionClick(_ sender:UIButton) {
|
||
navigationController?.popViewController(animated: true)
|
||
}
|
||
}
|