Reputation: 1537
I did the following to make the navigationbar just white.
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
So I set every UIViewController to "not under top/bot bar". This looks as I want. But when I make an UIImagePicker for example it looks like this:
So I tried the following:
let imagePicker = UIImagePicker()
imagePicker.edgesForExtendedLayout = []
But it doesnt work. How I have to do this?
Kindly Regards!
Upvotes: 1
Views: 16517
Reputation: 1537
I had to add:
UINavigationBar.appearance().isTranslucent = false
into my AppDelegate.
Thank you to Fonix and dfd
Upvotes: 3
Reputation:
Try this in your AppDelegate didFinishLaunchingWithOptions:
UINavigationBar.appearance().barTintColor = UIColor.white
UINavigationBar.appearance().isTranslucent = false
// these next lines aren't needed if you like the default
UINavigationBar.appearance().titleTextAttributes = [NSForegroundColorAttributeName: UIColor.black] // shouldn't be needed, but if you want something
UINavigationBar.appearance().tintColor = UIColor.blue
I'm pretty sure you need to set the isTranslucent to false.
Upvotes: 1
Reputation: 11597
Isnt the navigation bar white by default? going like
UINavigationBar.appearance().shadowImage = UIImage()
UINavigationBar.appearance().setBackgroundImage(UIImage(), for: .default)
is setting the background to an image with no data, so it will be transparent. If you really need to set the colour of the nav bar, use
UINavigationBar.appearance().barTintColor = UIColor.white
instead of setting the background to an image. You may need
self.navigationController!.navigationBar.isTranslucent = false
inside viewDidLoad for each viewController, but try without it first
Upvotes: 8