Missing bottom line of iOS navigation bar

I make the navigation bar completely transparent by adding the following codes to viewWillAppear:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = UIImage()
self.navigationController?.navigationBar.translucent = true
self.navigationController?.navigationBar.barStyle = UIBarStyle.Black

Before the current view disappears, I reset the navigation bar by doing this in the viewDidDisappear method:

self.navigationController?.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default)
self.navigationController?.navigationBar.shadowImage = nil

but it turns out that the bottom line of the navigation bar is missing, here is an image that shows the normal navigation bar:

enter image description here

but it turns out that it looks like this:

enter image description here

any idea what is going on? and any solutions? thank

+4
source share
1 answer

it is missing because you set the shadow image to zero. To fix this, delete the line below:

self.navigationController?.navigationBar.shadowImage = nil
+1
source

All Articles