ios UIView animateWithDuration:duration:animations:completion:似乎有一个默认的过渡?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10794763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 18:32:01  来源:igfitidea点击:

UIView animateWithDuration: duration: animations: completion: seems to have a default transition?

objective-ciosanimationuiview

提问by Fitzy

In my program, I want to create an animation that will move at a constant speed. It appears that the animation starts slowly, speeds up and then finishes slowly. Is there any way to change this?

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

回答by adig

You can change this setting by using the animateWithDuration:delay:options:animations:completion:alternative. Send an UIViewAnimationOptionmask for the option parameter. These are the options that you're interested in :

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

 UIViewAnimationOptionCurveEaseInOut 
 UIViewAnimationOptionCurveEaseIn   
 UIViewAnimationOptionCurveEaseOut 
 UIViewAnimationOptionCurveLinear 

The documentation says that UIViewAnimationOptionCurveEaseInOutis the default value.

文档说这UIViewAnimationOptionCurveEaseInOut是默认值。

See the documentation for more details : http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html

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

回答by Paul T.

You should use, that will solve your problem

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

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