Create a auto hide popup with swift

Mar 05, 2015 19:401

So i needed a popup kind of view for an IOS app. The purpose of the popup was to display a message when a gesture action has taken place. Gestures can be confusing for people and for complex gesture its better to show some kind of message so that user knows that something happened. Here is the code.

1) Take a ViewController. Add a button and a UIVIew on it. In the UIView add a label. This label can be changed based on the message that needs to be passed.
Screenshot at Mar 05 19-44-25

2) In the view controller we add our code.  Code has 2 methods.  On button click i am displaying the popup and triggering a timer.  2nd method gets called when the timer is over. In the 2nd method i hide the popup with animation.