Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
   }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading