| | |
| | | // |
| | | // BaseNavigationController.swift |
| | | // BrokerDriver |
| | | // |
| | | // Created by 无故事王国 on 2023/4/24. |
| | | // |
| | | // |
| | | // BaseNavigationController.swift |
| | | // BrokerDriver |
| | | // |
| | | // Created by 无故事王国 on 2023/4/24. |
| | | // |
| | | |
| | | import UIKit |
| | | import JQTools |
| | | |
| | | class BaseNav: UINavigationController,UINavigationControllerDelegate { |
| | | |
| | | // private var popDelegate: UIGestureRecognizerDelegate? |
| | | |
| | | // private var popDelegate: UIGestureRecognizerDelegate? |
| | | |
| | | |
| | | /// 需要透明Nav的VC |
| | | private var lucencyVCs = [RechargeRecordVC.self,RechargeCenterVC.self] |
| | | /// 需要透明Nav的VC |
| | | private var lucencyVCs = [RechargeRecordVC.self,RechargeCenterVC.self] |
| | | |
| | | private let img = UIImage.jq_gradient([UIColor(hexStr: "#FD8C02"),UIColor(hexStr: "#FD7202")], size: CGSize(width: JQ_ScreenW, height: JQ_NavBarHeight), radius: 0, locations: [0,1], direction: .vertical) |
| | | |
| | | open override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | self.navigationBar.barTintColor = .white |
| | | self.navigationBar.titleTextAttributes = [.font:UIFont.systemFont(ofSize: 18, weight: .medium), .foregroundColor:UIColor.white] |
| | | self.navigationBar.tintColor = UIColor.black |
| | | self.navigationBar.shadowImage = UIImage() |
| | | self.navigationBar.isTranslucent = true |
| | | self.delegate = self |
| | | // self.popDelegate = self.interactivePopGestureRecognizer?.delegate |
| | | self.interactivePopGestureRecognizer?.delegate = self |
| | | /// 世界杯风格 |
| | | private var worldCupVCs = [SearchVC.self,WorldCupVC.self,WorldCupHeaderVC.self,WorldCupMenuVC.self,WorldCupContentVC.self,WorldCupRecordVC.self,WorldCupRankVC.self] |
| | | |
| | | private let img = UIImage.jq_gradient([UIColor(hexStr: "#FD8C02"),UIColor(hexStr: "#FD7202")], size: CGSize(width: JQ_ScreenW, height: JQ_NavBarHeight), radius: 0, locations: [0,1], direction: .vertical) |
| | | |
| | | open override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | self.navigationBar.barTintColor = .white |
| | | self.navigationBar.titleTextAttributes = [.font:UIFont.systemFont(ofSize: 18, weight: .medium), .foregroundColor:UIColor.white] |
| | | self.navigationBar.tintColor = UIColor.black |
| | | self.navigationBar.shadowImage = UIImage() |
| | | self.navigationBar.isTranslucent = true |
| | | self.delegate = self |
| | | // self.popDelegate = self.interactivePopGestureRecognizer?.delegate |
| | | self.interactivePopGestureRecognizer?.delegate = self |
| | | |
| | | |
| | | if #available(iOS 15.0, *) { |
| | | let scrollBar = UINavigationBarAppearance() |
| | | scrollBar.configureWithOpaqueBackground() |
| | | scrollBar.backgroundEffect = nil |
| | | scrollBar.shadowColor = nil |
| | | scrollBar.titleTextAttributes = [.foregroundColor:UIColor.white,.font:Def_NavFont] |
| | | scrollBar.backgroundColor = UIColor.clear |
| | | scrollBar.backgroundImage = img |
| | | |
| | | |
| | | let standardBar = UINavigationBarAppearance() |
| | | standardBar.configureWithOpaqueBackground() |
| | | standardBar.backgroundEffect = nil |
| | | standardBar.shadowColor = nil |
| | | standardBar.shadowImage = nil |
| | | standardBar.titleTextAttributes = [.foregroundColor:UIColor.white,.font:Def_NavFont] |
| | | standardBar.backgroundColor = UIColor.clear |
| | | standardBar.backgroundImage = img |
| | | |
| | | navigationBar.scrollEdgeAppearance = scrollBar //顶部透明 |
| | | navigationBar.standardAppearance = standardBar |
| | | }else { |
| | | navigationBar.titleTextAttributes = [.foregroundColor:UIColor.white,.font:Def_NavFont] |
| | | navigationBar.isTranslucent = true |
| | | navigationBar.setBackgroundImage(UIImage(), for: .default) |
| | | navigationBar.shadowImage = UIImage() |
| | | } |
| | | } |
| | | |
| | | open func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { |
| | | let status = lucencyVCs.contains(where: {$0 == viewController.classForCoder}) |
| | | if (navigationController.viewControllers.count == 1 || status) && !(viewController is WelfareVC){ |
| | | if #available(iOS 15.0, *) { |
| | | navigationBar.standardAppearance.backgroundImage = nil |
| | | navigationBar.scrollEdgeAppearance?.backgroundImage = nil |
| | | }else{ |
| | | navigationBar.setBackgroundImage(UIImage(), for: .default) |
| | | navigationBar.shadowImage = UIImage() |
| | | } |
| | | }else{ |
| | | if #available(iOS 15.0, *) { |
| | | navigationBar.standardAppearance.backgroundImage = img |
| | | navigationBar.scrollEdgeAppearance?.backgroundImage = img |
| | | }else{ |
| | | navigationBar.setBackgroundImage(img, for: .default) |
| | | } |
| | | } |
| | | } |
| | | |
| | | //侧滑 |
| | | public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { |
| | | if viewController == self.viewControllers[0] { |
| | | self.interactivePopGestureRecognizer!.delegate = self |
| | | }else{ |
| | | self.interactivePopGestureRecognizer!.delegate = nil |
| | | } |
| | | } |
| | | if #available(iOS 15.0, *) { |
| | | let scrollBar = UINavigationBarAppearance() |
| | | scrollBar.configureWithOpaqueBackground() |
| | | scrollBar.backgroundEffect = nil |
| | | scrollBar.shadowColor = nil |
| | | scrollBar.titleTextAttributes = [.foregroundColor:UIColor.white,.font:Def_NavFont] |
| | | scrollBar.backgroundColor = UIColor.clear |
| | | scrollBar.backgroundImage = img |
| | | |
| | | open override var childForStatusBarHidden: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | open override var childForStatusBarStyle: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | override var preferredStatusBarStyle: UIStatusBarStyle{ |
| | | return .lightContent |
| | | } |
| | | |
| | | let standardBar = UINavigationBarAppearance() |
| | | standardBar.configureWithOpaqueBackground() |
| | | standardBar.backgroundEffect = nil |
| | | standardBar.shadowColor = nil |
| | | standardBar.shadowImage = nil |
| | | standardBar.titleTextAttributes = [.foregroundColor:UIColor.white,.font:Def_NavFont] |
| | | standardBar.backgroundColor = UIColor.clear |
| | | standardBar.backgroundImage = img |
| | | |
| | | navigationBar.scrollEdgeAppearance = scrollBar //顶部透明 |
| | | navigationBar.standardAppearance = standardBar |
| | | }else { |
| | | navigationBar.titleTextAttributes = [.foregroundColor:UIColor.white,.font:Def_NavFont] |
| | | navigationBar.isTranslucent = true |
| | | navigationBar.setBackgroundImage(UIImage(), for: .default) |
| | | navigationBar.shadowImage = UIImage() |
| | | } |
| | | } |
| | | |
| | | open func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { |
| | | |
| | | if worldCupVCs.contains(where: {$0 == viewController.classForCoder}){ |
| | | navigationBar.standardAppearance.backgroundImage = UIImage(named: "bg_worldCup") |
| | | navigationBar.scrollEdgeAppearance?.backgroundImage = UIImage(named: "bg_worldCup") |
| | | return |
| | | } |
| | | |
| | | let status = lucencyVCs.contains(where: {$0 == viewController.classForCoder}) |
| | | if (navigationController.viewControllers.count == 1 || status) && !(viewController is WelfareVC){ |
| | | if #available(iOS 15.0, *) { |
| | | navigationBar.standardAppearance.backgroundImage = nil |
| | | navigationBar.scrollEdgeAppearance?.backgroundImage = nil |
| | | }else{ |
| | | navigationBar.setBackgroundImage(UIImage(), for: .default) |
| | | navigationBar.shadowImage = UIImage() |
| | | } |
| | | }else{ |
| | | if #available(iOS 15.0, *) { |
| | | navigationBar.standardAppearance.backgroundImage = img |
| | | navigationBar.scrollEdgeAppearance?.backgroundImage = img |
| | | }else{ |
| | | navigationBar.setBackgroundImage(img, for: .default) |
| | | } |
| | | } |
| | | } |
| | | |
| | | //侧滑 |
| | | public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { |
| | | if viewController == self.viewControllers[0] { |
| | | self.interactivePopGestureRecognizer!.delegate = self |
| | | }else{ |
| | | self.interactivePopGestureRecognizer!.delegate = nil |
| | | } |
| | | } |
| | | |
| | | open override var childForStatusBarHidden: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | open override var childForStatusBarStyle: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | override var preferredStatusBarStyle: UIStatusBarStyle{ |
| | | return .lightContent |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | class LoginNav: UINavigationController,UINavigationControllerDelegate { |
| | | |
| | | private var popDelegate: UIGestureRecognizerDelegate? |
| | | |
| | | open override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | self.navigationBar.barTintColor = .white |
| | | self.navigationBar.titleTextAttributes = [.font:UIFont.systemFont(ofSize: 18, weight: .medium), .foregroundColor:UIColor.black] |
| | | self.navigationBar.tintColor = UIColor.black |
| | | self.navigationBar.shadowImage = UIImage() |
| | | self.navigationBar.isTranslucent = true |
| | | self.delegate = self |
| | | self.popDelegate = self.interactivePopGestureRecognizer?.delegate |
| | | |
| | | |
| | | if #available(iOS 15.0, *) { |
| | | |
| | | // let img = UIImage.jq_gradient([UIColor(hexStr: "#FD8C02"),UIColor(hexStr: "#FD7202")], size: CGSize(width: JQ_ScreenW, height: JQ_NavBarHeight), radius: 0, locations: [0,1], direction: .vertical) |
| | | |
| | | let scrollBar = UINavigationBarAppearance() |
| | | scrollBar.configureWithOpaqueBackground() |
| | | scrollBar.backgroundEffect = nil |
| | | scrollBar.shadowColor = nil |
| | | scrollBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont] |
| | | scrollBar.backgroundColor = UIColor.clear |
| | | // scrollBar.backgroundImage = img |
| | | |
| | | |
| | | let standardBar = UINavigationBarAppearance() |
| | | standardBar.configureWithOpaqueBackground() |
| | | standardBar.backgroundEffect = nil |
| | | standardBar.shadowColor = nil |
| | | standardBar.shadowImage = nil |
| | | standardBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont] |
| | | standardBar.backgroundColor = UIColor.clear |
| | | // standardBar.backgroundImage = img |
| | | |
| | | navigationBar.scrollEdgeAppearance = scrollBar //顶部透明 |
| | | navigationBar.standardAppearance = standardBar |
| | | |
| | | |
| | | }else { |
| | | navigationBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont] |
| | | } |
| | | } |
| | | |
| | | open func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { |
| | | |
| | | |
| | | } |
| | | |
| | | //侧滑 |
| | | public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { |
| | | if viewController == self.viewControllers[0] { |
| | | self.interactivePopGestureRecognizer!.delegate = self.popDelegate |
| | | }else{ |
| | | self.interactivePopGestureRecognizer!.delegate = nil |
| | | } |
| | | } |
| | | |
| | | open override var childForStatusBarHidden: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | open override var childForStatusBarStyle: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | |
| | | private var popDelegate: UIGestureRecognizerDelegate? |
| | | |
| | | open override func viewDidLoad() { |
| | | super.viewDidLoad() |
| | | self.navigationBar.barTintColor = .white |
| | | self.navigationBar.titleTextAttributes = [.font:UIFont.systemFont(ofSize: 18, weight: .medium), .foregroundColor:UIColor.black] |
| | | self.navigationBar.tintColor = UIColor.black |
| | | self.navigationBar.shadowImage = UIImage() |
| | | self.navigationBar.isTranslucent = true |
| | | self.delegate = self |
| | | self.popDelegate = self.interactivePopGestureRecognizer?.delegate |
| | | |
| | | |
| | | if #available(iOS 15.0, *) { |
| | | |
| | | // let img = UIImage.jq_gradient([UIColor(hexStr: "#FD8C02"),UIColor(hexStr: "#FD7202")], size: CGSize(width: JQ_ScreenW, height: JQ_NavBarHeight), radius: 0, locations: [0,1], direction: .vertical) |
| | | |
| | | let scrollBar = UINavigationBarAppearance() |
| | | scrollBar.configureWithOpaqueBackground() |
| | | scrollBar.backgroundEffect = nil |
| | | scrollBar.shadowColor = nil |
| | | scrollBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont] |
| | | scrollBar.backgroundColor = UIColor.clear |
| | | // scrollBar.backgroundImage = img |
| | | |
| | | |
| | | let standardBar = UINavigationBarAppearance() |
| | | standardBar.configureWithOpaqueBackground() |
| | | standardBar.backgroundEffect = nil |
| | | standardBar.shadowColor = nil |
| | | standardBar.shadowImage = nil |
| | | standardBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont] |
| | | standardBar.backgroundColor = UIColor.clear |
| | | // standardBar.backgroundImage = img |
| | | |
| | | navigationBar.scrollEdgeAppearance = scrollBar //顶部透明 |
| | | navigationBar.standardAppearance = standardBar |
| | | |
| | | |
| | | }else { |
| | | navigationBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont] |
| | | } |
| | | } |
| | | |
| | | open func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) { |
| | | |
| | | |
| | | } |
| | | |
| | | //侧滑 |
| | | public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) { |
| | | if viewController == self.viewControllers[0] { |
| | | self.interactivePopGestureRecognizer!.delegate = self.popDelegate |
| | | }else{ |
| | | self.interactivePopGestureRecognizer!.delegate = nil |
| | | } |
| | | } |
| | | |
| | | open override var childForStatusBarHidden: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | open override var childForStatusBarStyle: UIViewController? { |
| | | return self.topViewController |
| | | } |
| | | |
| | | } |