繁体   English   中英

UIView animatewithduration-iOS

[英]UIView animatewithduration - iOS

我正在尝试使用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);]

一旦标签即将达到740,它就会减速。 是否有可能使匀速运动到B点而不是放慢速度?

用这个:

[UIView animateWithDuration:3 delay:0 options:UIViewAnimationTransitionNone | UIViewAnimationOptionCurveLinear animations:^(void){ 
...

只需将动画选项更改为UIViewAnimationOptionCurveLinear以使动画使用删除所有的加速和减速或UIViewAnimationOptionCurveEaseIn来保持缓慢的开始而不结束时减速。

您所看到的是预期的, 甚至已记录在案 (请参阅下文)。 默认情况下,动画的开始和结束均缓慢:

讨论区

此方法使用UIViewAnimationOptionCurveEaseInOut立即执行指定的动画。

在选项中包括UIViewAnimationCurveLinear而不是UIViewAnimationTransitionNone UIViewAnimationTransitionNone不适用于此类动画。 它用于视图控制器转换。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM