[英]UIView animatewithduration - iOS
I'm trying to move a label from point A to point B using UIView animateWithDuration as below 我正在尝试使用UIView animateWithDuration将标签从A点移动到B点,如下所示
[UIView animateWithDuration:3 delay:0 options:UIViewAnimationTransitionNone animations:^(void){
label.alpha = 1;
label.center = CGPointMake(label.center.x , label.center.y +740);
}completion:^(BOOL Finished){
label.alpha = 0;
label.center = CGPointMake(label.center.x , label.center.y - 740);]
Once the label is about to reach 740, it decelrates. 一旦标签即将达到740,它就会减速。 Is it possible to have uniform motion to point B instead of slowing down?
是否有可能使匀速运动到B点而不是放慢速度?
Use this: 用这个:
[UIView animateWithDuration:3 delay:0 options:UIViewAnimationTransitionNone | UIViewAnimationOptionCurveLinear animations:^(void){
...
Just change the animation option to UIViewAnimationOptionCurveLinear
to have the animation use remove all the acceleration and deceleration or UIViewAnimationOptionCurveEaseIn
to keep the slow start without decelerating at the end. 只需将动画选项更改为
UIViewAnimationOptionCurveLinear
以使动画使用删除所有的加速和减速或UIViewAnimationOptionCurveEaseIn
来保持缓慢的开始而不结束时减速。
What you are seeing is expected and even documented (see below). 您所看到的是预期的, 甚至已记录在案 (请参阅下文)。 By default the animation both begins and ends slowly:
默认情况下,动画的开始和结束均缓慢:
Discussion讨论区
This method performs the specified animations immediately using the
UIViewAnimationOptionCurveEaseInOut
.此方法使用
UIViewAnimationOptionCurveEaseInOut
立即执行指定的动画。
Include UIViewAnimationCurveLinear
in the options instead of UIViewAnimationTransitionNone
. 在选项中包括
UIViewAnimationCurveLinear
而不是UIViewAnimationTransitionNone
。 UIViewAnimationTransitionNone
is not meant for this kind of animation. UIViewAnimationTransitionNone
不适用于此类动画。 It's meant for view controller transitions. 它用于视图控制器转换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.