//
// ViewController.swift
// TestApp2
//
// Created by Divakar Singh on 3/7/17.
// Copyright (c) 2017 Divakar Singh. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
var stepper : UIStepper!
var label1 : UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// create label
label1 = UILabel()
label1.frame = CGRect(x: 50, y: 100, width: 48, height: 36)
label1.text = "0"
view.addSubview(label1)
// create stepper
stepper = UIStepper()
stepper.sizeToFit()
stepper.center = CGPoint(x: 50, y: 200)
stepper.wraps = true
stepper.autorepeat = true
stepper.maximumValue = 10
view.addSubview(stepper)
stepper.addTarget(self, action: "stepperValueChanged:", forControlEvents: UIControlEvents.TouchUpInside)
}
func stepperValueChanged(sender: UIStepper) {
label1.text = Int(sender.value).description
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
No comments:
Post a Comment