美文网首页
微调器或叫步进器(UIStepper)

微调器或叫步进器(UIStepper)

作者: 焉逢12 | 来源:发表于2017-03-04 14:01 被阅读0次
    var step : UIStepper!
    var label : UILabel!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        step = UIStepper(frame: CGRect(x: 100, y: 100, width: 200, height: 50))
        //设置stepper的范围与初始值
        step.maximumValue=10
        step.minimumValue=1
        step.value=5.5
        //设置每次增减的值
        step.stepValue=0.5
        //设置stepper可以按住不放来连续更改值
        step.isContinuous=true
        //设置stepper是否循环(到最大值时再增加数值从最小值开始)
        step.wraps=true
        step.addTarget(self, action:#selector(stepClick), for: .valueChanged)
        self.view.addSubview(step)
        
        
    }

    func stepClick()
    {
        print("\(step.value)")
    }

相关文章

网友评论

      本文标题:微调器或叫步进器(UIStepper)

      本文链接:https://www.haomeiwen.com/subject/tuxjgttx.html