Abhishek Mitra
Abhishek Mitra

Reputation: 3395

Statusbar become transparent

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.

Upvotes: 0

Views: 1397

Answers (3)

Bhavesh Dhaduk
Bhavesh Dhaduk

Reputation: 1906

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

Upvotes: 0

Abhishek Mitra
Abhishek Mitra

Reputation: 3395

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

Upvotes: 1

glyvox
glyvox

Reputation: 58049

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

Upvotes: 1

Related Questions