Reputation: 3395
I need to remove the UINavigationBar
shadow image.
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:
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
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
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
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