动画结束时会变慢

时间:2013-12-17 14:44:17

标签: ios objective-c uikit uianimation

我有一个翻译动画,将我的按钮从A移动到B.

该路线如下:

1)按钮慢慢加速 2)在动画中间达到它的速度的顶峰 3)接近结束时减速

这是我的代码

[UIView animateWithDuration:speed
                      delay:delay
                    options:UIViewAnimationOptionAllowUserInteraction
                 animations:^(void){
                     [UIView setAnimationRepeatCount:5];
                     cloud.frame = (CGRectMake(cloud.frame.origin.x,   
cloud.frame.origin.y+900, cloud.frame.size.width, cloud.frame.size.height));

                 }completion:nil];

我希望我的动画始终保持相同的速度。

我怎样才能做到这一点?

2 个答案:

答案 0 :(得分:7)

UIViewAnimationOptionCurveLinear添加到动画选项中,如下所示:

[UIView animateWithDuration:speed
                      delay:delay
                    options:UIViewAnimationOptionAllowUserInteraction|UIViewAnimationOptionCurveLinear
                 animations:^(void){
                     [UIView setAnimationRepeatCount:5];
                     cloud.frame = (CGRectMake(cloud.frame.origin.x,   
cloud.frame.origin.y+900, cloud.frame.size.width, cloud.frame.size.height));

                 }completion:nil];

答案 1 :(得分:1)

我想你想尝试将“option”参数设置为:

UIViewAnimationOptionCurveLinear