Make a simple popup window in iOS SDK (Swift)

I was asked to create a simple popup window on a project I’m currently working on and I haven’t found any nice implementation of a clean popup window with the iOS SDK.

import UIKit

class PopUpViewControllerSwift : UIViewController {
 
 @IBOutlet weak var popUpView: UIView!
 @IBOutlet weak var messageLabel: UILabel!
 @IBOutlet weak var logoImg: UIImageView!
 
 override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
 super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
 }

 required init?(coder aDecoder: NSCoder) {
 super.init(coder: aDecoder)
 }
 
 override func viewDidLoad() {
 super.viewDidLoad()
 self.view.frame = CGRectMake(0, 0, UIScreen.mainScreen().bounds.size.width, UIScreen.mainScreen().bounds.size.height) //sets the
 self.view.backgroundColor = UIColor.clearColor()
 
 self.popUpView.layer.cornerRadius = 5
 self.popUpView.layer.shadowOpacity = 0.8
 self.popUpView.layer.shadowOffset = CGSizeMake(0.0, 0.0)
 }
 
 @IBAction func closePopup(sender: AnyObject) {
 self.dismissViewControllerAnimated(true, completion: nil)
 }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s