【问题标题】:UIView animatewithduration - iOSUIView animatewithduration - iOS
【发布时间】:2012-10-14 06:19:34
【问题描述】:

我正在尝试使用 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 点而不是减速?

【问题讨论】:

    标签: ios uiviewanimation uiviewanimationtransition


    【解决方案1】:

    使用这个:

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

    【讨论】:

      【解决方案2】:

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

      您所看到的是预期和even documented(见下文)。默认情况下,动画开始和结束都很慢:

      讨论

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

      【讨论】:

        【解决方案3】:

        在选项中包含UIViewAnimationCurveLinear 而不是UIViewAnimationTransitionNoneUIViewAnimationTransitionNone 不适用于这种动画。它适用于视图控制器转换。

        【讨论】:

          猜你喜欢
          • 2014-03-17
          • 1970-01-01
          • 2015-03-29
          • 1970-01-01
          • 2020-02-05
          • 1970-01-01
          • 2015-01-07
          • 2013-11-24
          • 2012-01-13
          相关资源
          最近更新 更多