如何为UIView动画设置相同的速度

时间:2016-03-11 17:26:54

标签: ios animation uislider

我想将速度设置为UISlider,以使其更顺畅地移动。

以下是我试图制作动画的方法:

 UIView.animateWithDuration(6, delay: 0.0, options: UIViewAnimationOptions.TransitionCurlUp, animations: { () -> Void in

            self.videoSlider.setValue(time, animated: true)
            if self.videoSlider.value == self.videoSlider.maximumValue {
                self.playerLayer.stop()
                self.playBigButton.hidden = false
                self.pauseButton.hidden = true
                self.playButton.hidden = false
            }

            }, completion: { (finished: Bool) -> Void in

        })

但它在开始,中间和结束时以不同的速度移动。

1 个答案:

答案 0 :(得分:0)

尝试为动画添加.CurveLinear选项,如下所示:

 UIView.animateWithDuration(6, 
                      delay: 0.0, 
                    options: [UIViewAnimationOptions.TransitionCurlUp, .CurveLinear],
                  animations: { () -> Void in

            self.videoSlider.setValue(time, animated: true)
            if self.videoSlider.value == self.videoSlider.maximumValue {
                self.playerLayer.stop()
                self.playBigButton.hidden = false
                self.pauseButton.hidden = true
                self.playButton.hidden = false
            }

            }, completion: { (finished: Bool) -> Void in

        })