【问题标题】:Can't start rotation-based animations longer than rotation duration?无法启动比旋转持续时间更长的基于旋转的动画?
【发布时间】:2014-09-12 02:22:12
【问题描述】:

所以,在我的旋转处理程序中,我正在为横向模式做一些布局。我想在旋转完成后执行一些额外的动画,所以我将持续时间增加到一个更大的值并开始一个关键帧类型的动画。

我发现由于某种原因我无法有效地增加持续时间。无论我将持续时间设置为什么,下面的代码似乎都在旋转的时间跨度(0.4 秒或其他任何时间)内运行。

旋转动画是否已经在进行中,导致无法启动较长的动画?

感谢您的帮助。

  - (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)    toInterfaceOrientation duration:(NSTimeInterval) duration
  {
     duration = 10.0;  // overriding the duration to a longer value

  // running some keyframed animation over the longer animation

       [UIView animateKeyframesWithDuration: duration delay:0.0    options:UIViewKeyframeAnimationOptionBeginFromCurrentState
                              animations:^{

                                  [UIView addKeyframeWithRelativeStartTime:0.0
                                                          relativeDuration:total_duration_sec
                                                                animations:^{ /*do some stuff */ }];

}

【问题讨论】:

    标签: ios animation


    【解决方案1】:

    在完成块中添加额外的动画。

    [UIView animateKeyframesWithDuration:duration delay:0.0 options:UIViewKeyframeAnimationOptionBeginFromCurrentState 动画:^{} completion:NULL];

    【讨论】:

    • 谢谢。实际上我已经尝试过,并且确实可以正常工作,但是我想知道为什么较长的关键帧(上图)没有?我觉得我可能会从这个答案中学到一些东西。此外,我可能想在旋转动画完成之前开始一个复杂的动画(例如从 90% 关键帧开始)。有什么想法吗?
    猜你喜欢
    • 2020-05-12
    • 2015-05-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 2015-08-24
    相关资源
    最近更新 更多