[英]Transition from one view controller to another with a change in colour of navigation bar
[英]is it possible to change colour of only one view controller's navigation bar?
我尝试在一个控制器中更改导航栏的颜色,但它会更改每个控制器中导航栏的颜色。
不要使用 segue 类型作为推送/显示。
您可以尝试礼物类型。 这会帮助你。
在这里,您将创建一个新的navigationController
。 因此,您可以为单个 viewController 自定义它。
我希望它对你有帮助。
在您的视图控制器上应用以下方法:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated: animated)
self.navigationController?.navigationBar.barTintColor = UIColor.red //current new color
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated: animated)
self.navigationController?.navigationBar.barTintColor = UIColor.white //other vc's color
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.