使用系统navigationBar

2019-08-22  本文已影响0人  纳兰沫
前面一个页面不需要显示导航栏 后面的页面需要展示 由此会发生跳转过程中的动画问题

解决办法

1.在系统NavigationViewController里面重写
protocol BaseNavigationProtocol:NSObjectProtocol {
    func shouldHiddenNavBar() -> Bool
}

extension UIViewController:BaseNavigationProtocol {
    @objc func shouldHiddenNavBar() -> Bool {
        return false
    }
}

internal func navigationController(_ navigationController: UINavigationController, willShow viewController: UIViewController, animated: Bool) {
        navigationController.setNavigationBarHidden(viewController.shouldHiddenNavBar(), animated: animated)
    }
2.在不需要导航条的地方重写@objc func shouldHiddenNavBar() -> Bool 方法并返回true

状态栏是透明的 导航条是半透明的 如果隐藏导航条而状态栏还在 是由于系统问题造成的 在ios11之前需要设置automaticallyAdjustsScrollViewInsets = false

        self.edgesForExtendedLayout = UIRectEdge.init(rawValue: 0);
        self.automaticallyAdjustsScrollViewInsets = false;
        if #available(iOS 11.0, *){
            mineTableView?.contentInsetAdjustmentBehavior = .never
        }
上一篇 下一篇

猜你喜欢

热点阅读