Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// FirstViewController.swift
// 012
//
// Created by chuck on 7/11/16.
// Copyright © 2016 chuck. All rights reserved.
//
import UIKit
class FirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.title = "My first View"
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)
self.view.addSubview(myButton)
}
// ボタンイベント
internal func onClickMyButton(sender: UIButton) {
let secondViewController = SecondViewController()
// SecondViewに移動する。
self.navigationController?.pushViewController(secondViewController, animated: true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment