I am trying to open new UIViewController with navigation bar when button is clicked.
But I can not see the navigation bar. I only see what I gave the background color.
Here is my code to show my UIViewController
@objc func ActionButtonTapped() {
let nav = UINavigationController(rootViewController: UploadTweetController())
nav.modalPresentationStyle = .fullScreen
present(nav, animated: true, completion: nil)
}
and viewDidLoad function of controller
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .red
}
I also tried nav.isNavigationBarHidden = false and nav.NavigationBar.isHidden = false but did not work.
CodePudding user response:
Your code is working fine. But by default the navigation bar is transparent. And you have given it no content. So it is there but you can't see it.
(Use the View Debugger if you don't believe me.)