[英]Navigation Controller Clear in Unwind Segue
I have a segue connecting two views. 我有一个连接两个视图的segue。 In the parent view, the navigation bar is a gray color, and in the child view, it's clear.
在父视图中,导航栏为灰色,在子视图中,它很清晰。 When unwinding the segue, the navigation bar in the parent controller is now clear as well.
展开segue时,父控制器中的导航栏现在也很清晰。 How to fix this?
如何解决这个问题?
Parent Controller 家长控制器
override func viewWillAppear(animated: Bool) {
self.navigationItem.title = "FEED"
self.navigationController?.navigationBar.barTintColor = UIColor(white:0.97, alpha:1.0)
let navBarLineView = UIView(frame: CGRectMake(0,
CGRectGetHeight((navigationController?.navigationBar.frame)!),
CGRectGetWidth((self.navigationController?.navigationBar.frame)!),
1))
navBarLineView.backgroundColor = UIColor(red:0.91, green:0.91, blue:0.92, alpha:1.0)
navigationController?.navigationBar.addSubview(navBarLineView)
}
Child Controller 儿童控制器
override func viewWillAppear(animated: Bool) {
self.navigationItem.title = "Space
self.navigationController?.navigationBar.barTintColor = UIColor.whiteColor()
navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
navigationController!.navigationBar.shadowImage = UIImage()
navigationController!.navigationBar.translucent = true
}
Setting background and shadow images to nil
in viewWillDisappear
method in the child controller worked fine for me when I wanted to restore default style of navigation bar: 当我想要恢复导航栏的默认样式时,子控制器中的
viewWillDisappear
方法中的背景和阴影图像设置为nil
正常工作:
override func viewWillDisappear(animated: Bool) {
navigationController!.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
navigationController!.navigationBar.shadowImage = nil
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.