43 lines
2.0 KiB
Swift
43 lines
2.0 KiB
Swift
//
|
|
// MP_NavigationController.swift
|
|
// MusicPlayer
|
|
//
|
|
// Created by Mr.Zhou on 2024/4/18.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
class MP_NavigationController: 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)
|
|
}
|
|
|
|
}
|