1

I call

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

in viewDidLoad.

Looks like this:

The separator line below the navigation bar disappears fine. The problem is, the status bar turns white. I want it to stay the same color as the navigation bar.

if just

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

in viewDidLoad, looks like this:

below the nav bar I have a view the exact same colour as the nav bar. I want this blended into one so it looks like the view below the nav bar is part of the nav bar.

luke
  • 2,743
  • 4
  • 19
  • 43

2 Answers2

1

It is working for me. Can u check this answer.

 self.navigationController?.navigationBar.isTranslucent = false
 self.navigationController?.navigationBar.barTintColor = UIColor.blue
 self.view.backgroundColor = UIColor.blue
 // Add your colour   
Chandan kumar
  • 1,074
  • 12
  • 31
  • `self.navigationController?.navigationBar.isTranslucent = false` done the trick. Thanks – luke Feb 15 '17 at 12:02
  • You can find the solution in the following link https://stackoverflow.com/questions/19226965/how-to-hide-uinavigationbar-1px-bottom-line – Gangadhar Sep 14 '21 at 23:39
0

Your statusbar become white after you call self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default), because your viewController.extendedLayoutIncludesOpaqueBars is NO, so when you set a opaque background image for the navigationBar, the navigationBar's background will not start from 0 but from 20, and nothing behind the statusbar, and statusbar showing as white.

So you must call viewController.extendedLayoutIncludesOpaqueBars = YES to avoid the white statusbar.

Custom shadowImage only work if you set a custom background image for the UINavigationBar.

MoLice
  • 301
  • 2
  • 7