重现发际线
Re-Showing the Hairline
我有两个 TableViewControllers
带有嵌入式导航控制器。 ViewController-1
在导航栏下显示 hairline/shadow 而 ViewController-2
在我导航到它时不显示它。使用 Push Segue
完成导航
要在 ViewController-2
中隐藏导航栏,我在 ViewWillAppear
中添加以下行:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = false
当我使用后退按钮返回 ViewController-1 时,发际线也在那里消失了,但我不希望它消失。有什么办法保证发际线不藏在ViewController-1
?
我试过了:
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black
和
self.navigationController?.navigationBar.backgroundColor = UIColor.whiteColor()
但收效甚微。
在 ViewController-2
的 viewWillDisappear
(或者可能是 viewDidDisappear
)方法中,添加代码以撤消在 viewWillAppear
中所做的更改。
self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = nil
self.navigationController?.navigationBar.translucent = true
我有两个 TableViewControllers
带有嵌入式导航控制器。 ViewController-1
在导航栏下显示 hairline/shadow 而 ViewController-2
在我导航到它时不显示它。使用 Push Segue
要在 ViewController-2
中隐藏导航栏,我在 ViewWillAppear
中添加以下行:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = false
当我使用后退按钮返回 ViewController-1 时,发际线也在那里消失了,但我不希望它消失。有什么办法保证发际线不藏在ViewController-1
?
我试过了:
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black
和
self.navigationController?.navigationBar.backgroundColor = UIColor.whiteColor()
但收效甚微。
在 ViewController-2
的 viewWillDisappear
(或者可能是 viewDidDisappear
)方法中,添加代码以撤消在 viewWillAppear
中所做的更改。
self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = nil
self.navigationController?.navigationBar.translucent = true