iOS 8动画bug [英] iOS 8 animation bug

查看:140
本文介绍了iOS 8动画bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的动画视图方法。

I have a simple method for animate view.

-(void)animateSelf
{
    CABasicAnimation * animation;

    animation = [CABasicAnimation animationWithKeyPath:@"position.y"];
    // settings ...
    [self.view.layer addAnimation:animation forKey:@"position.y"];

    animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    // settings ...
    [self.view.layer addAnimation:animation forKey:@"transform.rotation.z"];

    [UIView animateWithDuration: 1.0 animations:^{
        CGRect rect = self.view.frame;
        rect.origin.y += 800;
        self.view.frame = rect;
    } completion:nil];
}

对于iOS 7,它运作良好。但对于iOS 8,动画表现不可预测。有没有办法将这些动画组合成iOS 8?

For iOS 7 it worked well. But for iOS 8 animation behaves unpredictably. Is there a way to combine these animations for iOS 8?

我试图用另一个CABasicAnimation替换animateWithDuration:但它没有帮助。
view.frame日志是正确的,但view.frame的动画跳出了模糊的原点。

I tried to replace animateWithDuration: by another CABasicAnimation, but it did not help. The view.frame logs are correct, but the animation of view.frame jumps out of obscure origin.

删除的CABasicAnimation后position.y (第一个)错误消失。

After removing CABasicAnimation for position.y (the first one) bug is gone.

推荐答案

你有三个动画:


  1. 您为图层的位置设置动画

  2. 您为图层的转换设置动画

  3. 您可以为视图的框架设置动画动画图层的位置

  1. You animate the layer's position
  2. You animate the layer's transform
  3. You animate the view's frame which in turn animates the layer's position.

动画1和3发生碰撞。


  • 在iOS 7上,行为是动画3取消动画1.

  • 在iOS 8上行为是动画1和3同时运行(添加动画)。

我建议您删除动画1并查看相关的< a href =https://developer.apple.com/videos/wwdc/2014/ =noreferrer> WWDC 2014 视频(我想我t 构建可中断和响应的交互)。

I suggest you just remove animation 1 and also check out the related WWDC 2014 video (I think it was Building Interruptible and Responsive Interactions).

这篇关于iOS 8动画bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆