UIView animateWithDuration:duration:animations:completion:似乎有默认转换?

时间:2012-05-29 07:24:52

标签: objective-c ios animation uiview

在我的程序中,我想创建一个以恒定速度移动的动画。看起来动画开始缓慢,加速然后慢慢结束。有没有办法改变这个?

2 个答案:

答案 0 :(得分:22)

您可以使用animateWithDuration:delay:options:animations:completion:替代方案更改此设置。为选项参数发送UIViewAnimationOption掩码。这些是您感兴趣的选项:

 UIViewAnimationOptionCurveEaseInOut 
 UIViewAnimationOptionCurveEaseIn   
 UIViewAnimationOptionCurveEaseOut 
 UIViewAnimationOptionCurveLinear 

文档说明UIViewAnimationOptionCurveEaseInOut是默认值。

有关详细信息,请参阅文档:http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

答案 1 :(得分:16)

您应该使用,这将解决您的问题

[UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionCurveLinear  animations:^{
        //code with animation
    } completion:^(BOOL finished) {
        //code for completion
    }];