iOS Tutorials: Creating a pop up with ViewController

SWIFT 4.2 | XCODE 9.4.1


The tutorial today uses UIViewController as a pop over. The scenario here is, say you are on a landing page with buttons, and you would like to customize your own pop up to your own design when you click on the buttons. The concept should be similar.


Be aware that there are 2 UIViewController here:

1) The first UIViewController is the Landing Page with an UIImageView, Button and Label.

2) The second UIViewController is the pop up with View consists of Label, UITextField and Button.

To create the segue, simply press Control + Drag it to the next screen and edit some of the attributes of the segue to fit the one shown below.

Not much customizing will be done on the landing page, we will proceed to add some codes for the pop up view controller.


Much can be done here, but my point is to illustrate the pop up. Create an IBOutlet for UIView that contains all the objects in it.

You could customize the View to whatever you would like, in my case, I only add corner radius, background color and gesture recognizer. Here we are setting the background color black with an attributes of alpha which would make it less dark. And with gesture recognizer, we would like to dismiss the view, if the user tap anywhere outside of the pop up.

class PopUpViewController: UIViewController {

    @IBOutlet weak var popUpView: UIView!
    @IBOutlet weak var registerButton: UIView!
    override func viewDidLoad() {

    func configureView(){
        popUpView.layer.cornerRadius = 6
        registerButton.layer.cornerRadius = 6
        self.view.backgroundColor =
        self.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(dismissView)))
    @objc func dismissView(){
        self.dismiss(animated: false, completion: nil)



With all that is being done, let’s see the result

The project is uploaded to GitHub

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *