In my AppDelegate
I configure my navigation bar as follows:
func setupNavBar() {
let barAppearance = UINavigationBar.appearance()
barAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: appRed]
barAppearance.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
barAppearance.shadowImage = UIImage()
barAppearance.isTranslucent = true
}
This works well - until I want to display a UIImagePickerController
from one of my UIViewControllers
- the images go beyond the bar as its translucent - I need to be able to temporarily make the nav bar white, and then make it translucent again when the picker controller is dismissed:
I tried fixing this by adding the last two lines to the code:
let pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.allowsEditing = false
pickerController.mediaTypes = ["public.image"]
pickerController.sourceType = .savedPhotosAlbum
self.navigationController?.navigationBar.backgroundColor = .white
self.navigationController?.navigationBar.isTranslucent = false
self.present(pickerController, animated: true, completion: nil)
This doesn't seem to work though.