【发布时间】:2017-12-29 17:42:15
【问题描述】:
我已在应用程序的导航栏中嵌入,一切正常,除了进入我以编程方式设置导航栏的视图时(转到设置,重置功能)。
它只显示自定义导航栏,这没问题,但如果我实现自定义后退按钮,整个应用程序的导航栏与有问题的导航栏相同(现在它到处都显示重置和设置按钮)。
有没有办法让导航栏只针对该特定视图进行自定义?
部分代码:
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)
}
【问题讨论】:
标签: ios swift label uinavigationbar uinavigationitem