我有一个连接两个视图的segue。在父视图中,导航栏为灰色,在子视图中,它很清晰。展开segue时,父控制器中的导航栏现在也很清晰。如何解决这个问题?
家长控制器
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)
}
儿童控制器
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
}
答案 0 :(得分:0)
当我想要恢复导航栏的默认样式时,子控制器中的nil
方法中的背景和阴影图像设置为viewWillDisappear
正常工作:
override func viewWillDisappear(animated: Bool) {
navigationController!.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
navigationController!.navigationBar.shadowImage = nil
}