How to push ViewController on full screen from modally presented ViewController with navigation controller iOS 13?

8.2k Views Asked by At

I have a situation where I have three viewcontroller let suppose VC1, VC2 and VC3, and I presented VC2 on VC1 modally with navigation controller like

   let nav = UINavigationController(rootViewController: VC2)
   self.present(nav, animation:true)

What I want push VC3 overfullscreen from VC2 without changing the Presentation style of VC2 in iOS 13+. currently its overCurrentContext.

1

There are 1 best solutions below

2
Sumesh Sivan On

If you are adding the view controller VC3 as the root view controller of a navigation controller, then you need to modalPresentationStyle as overFullScreen to the navigation controller.

let nav = UINavigationController(rootViewController: VC3)
nav.modalPresentationStyle = .overFullScreen
self.present(nav, animation: true)

If you are directly presenting VC3, then do it like this.

VC3.modalPresentationStyle = .overFullScreen
self.present(VC3, animation: true)