diff --git a/Sources/UINavigationController+WXNavigationBar.swift b/Sources/UINavigationController+WXNavigationBar.swift index 9d68c0d..a4ec024 100644 --- a/Sources/UINavigationController+WXNavigationBar.swift +++ b/Sources/UINavigationController+WXNavigationBar.swift @@ -62,6 +62,7 @@ extension UINavigationController { let cls = UINavigationController.self swizzleMethod(cls, #selector(UINavigationController.pushViewController(_:animated:)), #selector(UINavigationController.wx_pushViewController(_:animated:))) swizzleMethod(cls, #selector(UINavigationController.setViewControllers(_:animated:)), #selector(UINavigationController.wx_setViewControllers(_:animated:))) + swizzleMethod(cls, #selector(UINavigationController.viewDidLoad), #selector(UINavigationController.wx_navigationViewDidLoad)) }() func configureNavigationBar() { @@ -128,6 +129,14 @@ extension UINavigationController { } + @objc private func wx_navigationViewDidLoad() { + let type = "\(self.classForCoder)" + let set = WXNavigationBarManger.shared.blackUINavigationControllers + let enableWXNavigationBar: Bool = set.contains(type) ? false : true + wx_enableWXNavigationBar = enableWXNavigationBar + wx_navigationViewDidLoad() + } + private func enableFullscreenPopGesture() { guard let gestureRecognizers = interactivePopGestureRecognizer?.view?.gestureRecognizers else { return diff --git a/Sources/WXNavigationBar.swift b/Sources/WXNavigationBar.swift index e695aa4..7cf1321 100644 --- a/Sources/WXNavigationBar.swift +++ b/Sources/WXNavigationBar.swift @@ -7,6 +7,18 @@ import UIKit +public class WXNavigationBarManger { + public static let shared = WXNavigationBarManger() + /// 黑名单 + var blackUINavigationControllers: Set = [] + + /// 启动 WXNavigationBar黑名单,黑名单内的UINavigationController将关闭WXNavigationBar + /// - Parameter blackUINavigationControllers: 黑名单(类名字符串集合) + public func setup(_ blackUINavigationControllers: Set = []) { + self.blackUINavigationControllers = blackUINavigationControllers + } +} + public class WXNavigationBar: UIView { /// Global settings of NavigationBar @@ -116,7 +128,8 @@ public class WXNavigationBar: UIView { containerView.addSubview(subView) } - public static func setup() { + public static func setup(_ blackUINavigationControllers: Set = []) { + WXNavigationBarManger.shared.setup(blackUINavigationControllers) UIApplication.runOnce } }