0

I am writing this in viewDidLoad() for the same

self.navigationController?.navigationBar.shadowImage = UIImage()

However this doesn't work on iOS versions < 11 What should I do in an order to remove shadow image irrespective of iOS version.

Getting: Getting now Expected: Expectation

Doj Yias Lem
  • 137
  • 8
  • 2
    Possible duplicate of [How to hide UINavigationBar 1px bottom line](https://stackoverflow.com/questions/19226965/how-to-hide-uinavigationbar-1px-bottom-line) – Hitesh Surani Sep 13 '18 at 13:05

2 Answers2

7

Try the following code:

 self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
 self.navigationController?.navigationBar.shadowImage = UIImage()
Dimple
  • 788
  • 1
  • 11
  • 27
3

In your viewDiDLoad() add this:

self.navigationController?.navigationBar.setValue(true, forKey: "hidesShadow")

For me worked

Enea Dume
  • 3,014
  • 3
  • 21
  • 36