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

Fit*_*tzy 13 animation objective-c uiview ios

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

adi*_*dig 22

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

 UIViewAnimationOptionCurveEaseInOut 
 UIViewAnimationOptionCurveEaseIn   
 UIViewAnimationOptionCurveEaseOut 
 UIViewAnimationOptionCurveLinear 
Run Code Online (Sandbox Code Playgroud)

文档说这UIViewAnimationOptionCurveEaseInOut是默认值.

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


Pau*_* T. 17

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

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