Created
June 30, 2016 22:20
-
-
Save chuck0523/ac782524119c3b627054ffc8be592c2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// 010 | |
// | |
// Created by chuck on 7/1/16. | |
// Copyright © 2016 chuck. All rights reserved. | |
// | |
import UIKit | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
super.view.backgroundColor = UIColor.cyanColor() | |
let myButton: UIButton = UIButton() | |
myButton.frame = CGRectMake(0,0,200,40) | |
myButton.backgroundColor = UIColor.redColor() | |
myButton.layer.masksToBounds = true | |
myButton.setTitle("UIAlertを発動", forState: UIControlState.Normal) | |
myButton.setTitleColor(UIColor.whiteColor(), forState:.Normal) | |
myButton.layer.cornerRadius = 20.0 | |
myButton.layer.position = CGPoint(x: self.view.frame.width/2, y:200) | |
myButton.addTarget(self, action: "onClickMyButton:", forControlEvents: .TouchUpInside) | |
self.view.addSubview(myButton) | |
} | |
internal func onClickMyButton(sender: UIButton) { | |
let myAlert: UIAlertController = UIAlertController(title: "タイトル", message: "メッセージ", preferredStyle: .Alert) | |
let myOkAction = UIAlertAction(title: "OK", style: .Default) { | |
action in print("Action OK!!") | |
} | |
myAlert.addAction(myOkAction) | |
presentViewController(myAlert, animated: true, completion: nil) | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment