iOS Tutorials: Creating a pop up with ViewController

SWIFT 4.2 | XCODE 9.4.1

OVERVIEW

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.

CREATING VIEW

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.

CONFIGURING THE POP UP

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.

DEMOSTRATION

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 *

*
*