adjusting label to slider value swift

后端 未结 6 643
清歌不尽
清歌不尽 2021-01-01 14:34

I have a slider and label in my swift project. On the storyboard, I control dragged my slider onto my controller class for that page and created an outlet and also an action

6条回答
  •  囚心锁ツ
    2021-01-01 14:54

    Update the slider value in Main queue

    @IBAction func sliderValueChanged(sender: UISlider) {
        var currentValue = Int(sender.value)
        println("Slider changing to \(currentValue) ?")
        dispatch_async(dispatch_get_main_queue(){
            sliderVal.text = "\(currentValue) Km"
        })
    }
    

    I hope this is helpful to you.

提交回复
热议问题