Present VC programmatically

How to present UIViewController() inside of UINavigationController ? My controller presenting not fullscreen. I want my app to look like this enter image description here, but it is end up like this enter image description here

I making app without Storyboard(Programmatically)

let customVC = UIViewController()
customVC.view.backgroundColor = .green
customVC.modalPresentationStyle = .fullScreen

let navVC = UINavigationController(rootViewController: customVC)
self.present(navVC, animated: true, completion: nil)

>Solution :

   let customVC = DestinationController()

   let navVC = UINavigationController(rootViewController: customVC)
   // this line overFullScreen
   navVC.modalPresentationStyle = .overFullScreen
// for more style 
   navVC.modalTransitionStyle = .crossDissolve
   self.present(navVC, animated: true, completion: nil)

your class where you want to go or present

class DestinationController:UIViewController {
   override func viewDidLoad() {
        super.viewDidLoad() 
        view.backgroundColor = .red
   }
}

Leave a Reply