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

63 lines
2.3 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_TabBarController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/4/19.
//
import UIKit
///btabBar
class MPPositive_TabBarController: UITabBarController {
//tabBar
private lazy var customTabBar:MPPositive_CustomTabBar = .init(frame: .init(x: 0, y: 0, width: screen_Width, height: 72*width))
private lazy var bottomView:MPPositive_BottomShowView = .init(frame: .init(x: 0, y: 0, width: 351, height: 82))
override func viewDidLoad() {
super.viewDidLoad()
self.setValue(customTabBar, forKey: "tabBar")
//
let homeVC = MPPositive_NavigationController(rootViewController: MPPositive_HomeViewController())
let searchVC = MPPositive_NavigationController(rootViewController: MPPositive_SearchViewController())
let libraryVC = MPPositive_NavigationController(rootViewController: MPPositive_LibraryViewController())
viewControllers = [homeVC,searchVC,libraryVC]
//tabBaritem
tabBar.items?.forEach({ item in
item.isEnabled = false
})
tabBar.barTintColor = .clear
UITabBar.appearance().backgroundColor = .clear
tabBar.shadowImage = UIImage()
tabBar.backgroundImage = UIImage()
//View
view.addSubview(bottomView)
//View
bottomView.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.bottom.equalToSuperview().offset(82*width)
make.width.equalTo(351*width)
make.height.equalTo(82*width)
}
addNotification()
}
//
private func addNotification() {
//
NotificationCenter.notificationKey.add(observer: self, selector: #selector(switchAction(_:)), notificationName: .switch_tabBarItem)
}
deinit {
//
NotificationCenter.default.removeObserver(self)
}
}
//MARK: -
extension MPPositive_TabBarController {
//
@objc private func switchAction(_ sender:Notification) {
let tag = sender.object as! Int
selectedIndex = tag
}
//player
@objc private func pupPlayerAction(_ sender:Notification) {
}
}