I am showing a custom pop up over my main viewcontroller. For this I have created a viewcontroller in the storyboard (image shown), the corresponding class being as below.
class PopUpViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.view.backgroundColor = UIColor.black.withAlphaComponent(0.7) self.showAnimate() } func showAnimate() { self.view.alpha = 1.0 } func removeAnimate() { UIView.animate(withDuration: 0.0, animations: { self.view.alpha = 0.0; }, completion:{(finished : Bool) in if (finished) { self.view.removeFromSuperview() } }); } } Then in my main viewcontroller, I show this pop up on a button click as follows:
let popOverVC = UIStoryboard(name: "MainViewController", bundle: nil).instantiateViewController(withIdentifier: "popup") as! PopUpViewController self.addChildViewController(popOverVC) popOverVC.view.frame = self.view.bounds self.view.addSubview(popOverVC.view) popOverVC.didMove(toParentViewController: self) This makes the background of the main view controller black with opacity of 70% when the pop up is added. How can I make the navigation bar also have the same background effect?
I have tried updating:
self.view.window?.backgroundColor = UIColor.black.withAlphaComponent(0.7) and
self.navigationController?.navigationBar.backgroundColor = UIColor.black.withAlphaComponent(0.7) in viewDidLoad() but did not work. Any possible solution?

self.navigationController?.navigationBar.backgroundColor = UIColor(red:0.00, green:0.00, blue:0.00, alpha:0.7)?