My Scenario, I am trying to remove bottom line and shadow from UINavigationBar
using iOS 13 - Swift 5. Here, Before iOS 13 - Swift 5, I used below code for removing bottom line and shadow without changing navigation bar color. Now, It is not showing NavigationBar
color (I already set Bar Color and Background Color) also disabled Transulent.
Code:
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
How to fix this? Need to remove bottom line shadow and also want to give NavigationBar Colour.
For me, it only worked after changing the following (>= iOS13)
let navBarAppearance = UINavigationBarAppearance()
navBarAppearance.configureWithOpaqueBackground()
navBarAppearance.shadowColor = .clear
navBarAppearance.shadowImage = UIImage()
navigationController?.navigationBar.standardAppearance = navBarAppearance
navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
XCODE 13 - iOS 15
For Xcode 13 and targeting iOS ver 13 and above you can use this code:
if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = .red // Your color
appearance.shadowColor = .clear
appearance.shadowImage = UIImage()
navigationController?.navigationBar.standardAppearance = appearance;
navigationController?.navigationBar.scrollEdgeAppearance = navigationController?.navigationBar.standardAppearance
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With