Reputation: 6272
I am trying to remove a border from UINavigationBar
while making it completely white so that it blends with the background.
Here is the code which I have:
nav.navigationBar.standardAppearance.shadowColor = UIColor.white //also tried UIColor.clear
nav.navigationBar.barTintColor = UIColor.white
nav.navigationBar.backgroundColor = UIColor.white
nav.navigationBar.barStyle = .default
nav.navigationBar.isTranslucent = false
The end result is depicted in the image below. As you can see, my navigation bar is not completely white:
If I remove the line where I set shadowColor
I do get a white background, but with a line at the bottom.
I would appreciate if someone could help me to get the result which I want.
Upvotes: 0
Views: 43
Reputation: 16341
Check out this code:
let appearance = UINavigationBarAppearance()
appearance.backgroundColor = .white
appearance.shadowColor = .none
appearance.titleTextAttributes = [.foregroundColor: UIColor.white]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.white]
UINavigationBar.appearance().tintColor = .black
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
Upvotes: 1