1.Outlets and Actions
2.Presenting View Controllers
3.The Delegate Pattern
4.Tables
5.Navigation
6.MemeMe Techniques
Clike counter
ViewController -> UIViewm UILabel, UIButton
import UIKit
class ViewController: UIViewController {
override func viewDidLoad(){
super.viewDidLoad()
var label = UILabel()
label.frame = CGRectMake(150, 150, 60, 60)
label.text = "0"
self.view.addSubview(label)
var button = UIButton()
button.frame = CGRectMake(150, 250, 60, 60)
button.setTitle("click", forState: .Normal)
button.setTitleColor(UIColor.blueColor(), forState: .Normal)
self.view.addSubview(button)
}
}
import UIKit
class ViewController: UIViewController {
var count = 0
var label:UILabel!
override func viewDidLoad(){
super.viewDidLoad()
var label = UILabel()
label.frame = CGRectMake(150, 150, 60, 60)
label.text = "0"
self.view.addSubview(label)
self.label = label
var button = UIButton()
button.frame = CGRectMake(150, 250, 60, 60)
button.setTitle("click", forState: .Normal)
button.setTitleColor(UIColor.blueColor(), forState: .Normal)
self.view.addSubview(button)
button.addTarget(self, action: "incrementCount", forControlEvents:
UIControlEvents.TouchUpInside)
}
func incrementCount(){
self.count++
self.label.text = "\(self.count)"
}
}