younger_times
2023-04-24 ae6bc78fc4fde4f060277fb702fa001c529f0ba3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//
//  BaseNavigationController.swift
//  BrokerDriver
//
//  Created by 无故事王国 on 2023/4/24.
//
 
import UIKit
 
class BaseNavigationController: 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 = false
        self.delegate = self
        self.popDelegate = self.interactivePopGestureRecognizer?.delegate
 
 
        if #available(iOS 15.0, *) {
            let bar = UINavigationBarAppearance()
            bar.configureWithOpaqueBackground() //消除15的黑框
            bar.backgroundEffect = nil
            bar.shadowColor = nil
            bar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont]
            bar.backgroundColor = UIColor.white
            navigationBar.scrollEdgeAppearance = bar //顶部透明
            navigationBar.standardAppearance = bar
        }else {
            navigationBar.titleTextAttributes = [.foregroundColor:Def_NavFontColor,.font:Def_NavFont]
        }
    }
 
    open override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        viewController.hidesBottomBarWhenPushed = true
        super.pushViewController(viewController, animated: animated)
    }
 
    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
    }
 
}