Music_Player3/MusicPlayer/MP/MPPositive/ViewControllers/Base(基类,导航栏,标签栏)/MPPositive_BaseViewController.swift
2024-05-11 09:48:37 +08:00

59 lines
1.9 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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: "Poplogo"), 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)
}
}