0

I need to remove the UINavigationBar shadow image.

UINavigationBar contained line

so I'm using the code below:

self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
self.navigationController?.navigationBar.shadowImage = UIImage()

It is working perfectly, but the area behind the status bar became transparent, like the image below:

transparent area behind status bar

and I don't need this. It should be white. What should I do? Any help will be appreciated.

Thanks in Advance.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Abhishek Mitra
  • 3,335
  • 4
  • 25
  • 46

3 Answers3

1

This occurs beause the navigation bar does not have a specified bar tint color. If you want to have a navigation bar with a bar tint color, you can set it in the IB inspector or programmatically:

navigationController?.navigationBar.barTintColor = .white
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
1

Well I found the the answer:

It was just online statement, i.e:

navigationController?.navigationBar.isTranslucent = false

By adding this in viewDidLoad it started working as I wanted. I got helped from this post https://stackoverflow.com/questions/38796259/remove-shadow-line-below-navigation-bar-without-removing-bar-color

Abhishek Mitra
  • 3,335
  • 4
  • 25
  • 46
0

You have to hide the status bar to remove it.

1.  Open Info.plist file
2.  Click + button to add new key
3.  "UIViewControllerBasedStatusBarAppearance" set to NO
Bhavesh Dhaduk
  • 1,888
  • 15
  • 30