开发者

how to know when uislider animation ends

I'm using the setValue message of the UISlider class allowing animation, as follow:

[mySlider setValue :0.0 animated:YES]

I googled but found nothing on this: how to know when the anim开发者_JAVA百科ation (of the setValue) stops ?

Thanks

Vincent


I'm away from my machine at the moment so can't check the details, but what happens if you link the valueChanged action of the slider to something, does that get called before or after the animation is complete?


You can use UISlider like that to know when it start, changed or finished.

slider.addTarget(self, action: #selector(sliderDragStart(_:)), for: .touchDown)

slider.addTarget(self, action: #selector(sliderChanged(_:)), for: .valueChanged)

slider.addTarget(self, action: #selector(sliderDragEnd(_:)), for: .touchUpInside)

@objc func sliderDragStart(_ sender: UISlider)
{
    print("slider drag start")
}

@objc func sliderChanged(_ sender: UISlider)
{
    print("slider value changed")
}

@objc func sliderDragEnd(_ sender: UISlider)
{
    print("slider drag End")
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜