导航栏错误

时间:2017-12-29 17:42:15

标签: ios swift label uinavigationbar uinavigationitem

我已经嵌入应用程序的导航栏中,一切正常,除非进入我以编程方式设置导航栏的视图(segue to settings,reset function)。

它只显示自定义导航栏,这是正常的,但如果我实现自定义后退按钮,整个应用程序具有相同的导航栏和有问题的导航栏(现在它显示重置和设置按钮无处不在)。

有没有办法让导航栏只对该特定视图进行自定义?

部分代码:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
    self.navigationController?.navigationBar.shadowImage = UIImage()

    //Add gesture to MainLabel
    let tapLabel: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(resetTime))
    tapLabel.delegate = self
    mainLabel.isUserInteractionEnabled = true
    mainLabel.addGestureRecognizer(tapLabel)

    //Add gesture to UINavigationBar title
    let tapTitle: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(resetTime))
    tapTitle.delegate = self
    self.navigationItem.titleView = resetLabel
    self.navigationItem.titleView?.isUserInteractionEnabled = true
    self.navigationItem.titleView?.addGestureRecognizer(tapTitle)
}

1 个答案:

答案 0 :(得分:0)

是的,您可以在viewController的viewDidDisappear上隐藏导航按钮,在该控件中您需要自定义导航栏,并在viewDidAppear中取消隐藏您需要的按钮。