美文网首页
使用系统navigationBar

使用系统navigationBar

作者: 纳兰沫 | 来源:发表于2019-08-22 17:02 被阅读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
        }

相关文章

网友评论

      本文标题:使用系统navigationBar

      本文链接:https://www.haomeiwen.com/subject/vpcosctx.html