-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirstViewController.swift
51 lines (40 loc) · 1.57 KB
/
FirstViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// FirstViewController.swift
// NavigationController
//
// Created by 矢吹祐真 on 2015/12/12.
// Copyright © 2015年 矢吹祐真. All rights reserved.
//
import UIKit
class FirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Controllerのタイトルを設定する.
self.title = "My 1st View"
// Viewの背景色をCyanに設定する.
self.view.backgroundColor = UIColor.cyanColor()
// ボタンの定義をおこなう.
let myButton = UIButton(frame: CGRectMake(0,0,100,50))
myButton.backgroundColor = UIColor.orangeColor()
myButton.layer.masksToBounds = true
myButton.setTitle("ボタン", forState: .Normal)
myButton.layer.cornerRadius = 20.0
myButton.layer.position = CGPoint(x: self.view.bounds.width/2, y:200)
myButton.addTarget(self, action: "onClickMyButton:", forControlEvents: .TouchUpInside)
// ボタンをViewに追加する.
self.view.addSubview(myButton);
}
/*
ボタンイベント
*/
internal func onClickMyButton(sender: UIButton){
// 移動先のViewを定義する.
let secondViewController = SecondViewController()
// SecondViewに移動する.
self.navigationController?.pushViewController(secondViewController, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}