Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS navigation bar bottom line is missing

Tags:

ios

I makes the navigation bar completely transparent by adding the following codes in 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 disappear, 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 the little bottom line of the navigation bar is missing, here is the image that shows the normal navigation bar:

enter image description here

but it turns out being like this:

enter image description here

any idea about what is going on? and any solutions? thanks

like image 926
Junbang Huang Avatar asked Jun 08 '15 07:06

Junbang Huang


People also ask

How do I change the navigation bar on my Iphone?

A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.

What is Scrolledgeappearance?

The appearance settings for a standard-height navigation bar when the edge of scrollable content aligns with the edge of the navigation bar.

What is Istranslucent?

A Boolean value that indicates whether the navigation bar is translucent.


1 Answers

it's missing because you set shadow image to nil. To fix this, delete line below :

self.navigationController?.navigationBar.shadowImage = nil
like image 154
mgyky Avatar answered Oct 09 '22 11:10

mgyky