Skip to content

Instantly share code, notes, and snippets.

@kennylugo
Last active January 16, 2016 01:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennylugo/aa34d8f0ca0fb89d3db2 to your computer and use it in GitHub Desktop.
Save kennylugo/aa34d8f0ca0fb89d3db2 to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// HelloWorld
//
// Created by Kenny Batista on 1/15/16.
// Copyright © 2016 Kenny Batista. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(type: UIButtonType.System) as UIButton
button.frame = CGRectMake(100, 100, 100, 100)
button.backgroundColor = UIColor.redColor()
button.setTitle("Touch for a hello greeting", forState: .Normal)
button.addTarget(self, action: "showMessage", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(button)
}
func showMessage(){
//Here we store the UIAlertController object inside of the alertController constant.
let alertController = UIAlertController(title: "Welcome to my first app", message: "Hello World", preferredStyle: UIAlertControllerStyle.Alert)
//We add the OK button and it's action for when we tap it.
alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
//We pop up the object where the user could see in the interface.
self.presentViewController(alertController, animated: true, completion: nil)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment