Popup UIViewController

At the parent controller:

let vc = ViewController()
vc.modalPresentationStyle = .overCurrentContext
vc.modalTransitionStyle = .crossDissolve
present(vc, animated: true, completion: nil)

At the pop up controller, use this to enable showing the parent controller in the background:

self.definesPresentationContext = true

Don't forget to set a translucent background to your pop up controller.

-- Reference from: Presenting a popup view controller programmatically - Reddit --


To make your view controller shown as a popup, you should set the following:

popupVC.modalPresentationStyle = .OverCurrentContext
popupVC.modalTransitionStyle = .CrossDissolve

You should also design your view controller's position, size to make it look like a popup.

Here is my popup that i did before.

enter image description here

Tags:

Ios

Popup

Swift