//
// ViewController.swift
// UILabelTest
//
// Created by mac on 15/6/23.
// Copyright (c) 2015年 fangyuhao. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
var stepper:UIStepper!
var label:UILabel!
override func viewDidLoad() {
super.viewDidLoad()
stepper = UIStepper()
stepper.center = self.view.center
//设置stepper的范围与初始值
stepper.maximumValue = 10
stepper.minimumValue = 1
stepper.value = 5.5
//设置每次增减的值
stepper.stepValue = 0.5
//设置stepper可以按住不放来连续更改值
stepper.continuous = true
//设置stepper是否循环
stepper.wraps = true
stepper.addTarget(self, action: "stepperValueIschanged", forControlEvents: UIControlEvents.ValueChanged)
self.view.addSubview(stepper)
label = UILabel(frame: CGRectMake(100, 190, 300, 30))
label.text = "当前值为:\(stepper.value)"
self.view.addSubview(label)
// Do any additional setup after loading the view, typically from a nib.
}
func stepperValueIschanged(){
label.text = "当前值为:\(stepper.value)"
}
}