Music_Player3/MusicPlayer/MP/ViewControllers/Base(基类-导航栏-标签栏-计时器-播放器)/MPNavigationController.swift
Mr.zhou 96147c5e37 项目:Musicoo
版本:A面 1.0
构建:1.1
更新内容:对项目A面功能的实现,经测试确定各项功能无问题。
更新时间:2024年4月12日 11:20
上传状态:已上传App Connect
2024-04-12 11:19:58 +08:00

74 lines
3.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.

//
// MPNavigationController.swift
// MusicPlayer
//
// Created by Mr.Zhou on 2024/3/27.
//
import UIKit
///
class MPNavigationController: UINavigationController {
override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
if #available(iOS 15, *) {
let navBar = UINavigationBarAppearance()
navBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 20, weight: .heavy)]
navBar.backgroundEffect = nil
navBar.shadowColor = nil
//线
navBar.configureWithTransparentBackground()
navBar.backgroundColor = .clear
rootViewController.navigationController?.navigationBar.scrollEdgeAppearance = navBar
rootViewController.navigationController?.navigationBar.standardAppearance = navBar
}
rootViewController.navigationController?.navigationBar.isTranslucent = false
rootViewController.navigationController?.navigationBar.shadowImage = UIImage()
//
rootViewController.navigationController?.navigationBar.barTintColor = .clear
//
rootViewController.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor.white, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 20, weight: .heavy)]
rootViewController.navigationController?.navigationBar.tintColor = .white
let item = UIBarButtonItem(title: "", style: .plain, target: self, action: nil)
item.tintColor = .white
rootViewController.navigationItem.backBarButtonItem = item
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override init(nibName nibNameorNil:String?,bundle nibBundleOrNil:Bundle?){
super.init(nibName:nibNameorNil,bundle:nibBundleOrNil)
}
//pushViewController
//pushpushviewControllerhidesBottomBarWhenPushed
override func pushViewController(_ viewController: UIViewController, animated: Bool) {
viewController.hidesBottomBarWhenPushed = true
NotificationCenter.notificationKey.post(notificationName: .hidden_show)
super.pushViewController(viewController, animated: true)
viewController.hidesBottomBarWhenPushed = false
}
//popViewController
//viewControllerpushviewController
//viewControllerpopviewController
override func popViewController(animated: Bool) -> UIViewController? {
guard self.children.count != 1 else {
//pop
return super.popViewController(animated: true)
}
guard self.children.count == 2 else {
//viewControllerViewControllerhidesBottomBarWhenPushed = true
//tabbar
let count = self.children.count-2
let controller = self.children[count]
controller.hidesBottomBarWhenPushed = true
NotificationCenter.notificationKey.post(notificationName: .hidden_show)
return super.popViewController(animated: true)
}
//viewControllerViewController
//tabbar
let controller:UIViewController = self.children[0]
controller.hidesBottomBarWhenPushed = false
NotificationCenter.notificationKey.post(notificationName: .display_show)
return super.popViewController(animated: true)
}
}