【问题标题】:iOS CABasicAnimation animationWithKeyPath:@"transform.rotation" wobbleiOS CABasicAnimation animationWithKeyPath:@"transform.rotation" wobble
【发布时间】:2014-09-26 20:14:45
【问题描述】:

我有以下代码来旋转指南针。此代码在 iPhone 6 和 iPhone 5 上的 iOS 8 上运行良好。

但是,当在装有 iOS 7.1.2 的 iPhone 5S 上尝试此操作时,图像会偏离 Z 轴,在旋转时出现摆动/浮动。

正如我所说,这不会发生在运行 iOS 8 的 iPhone 5 或 6 上。

谁能给点建议?

float oldRad =  -manager.heading.trueHeading * M_PI / 180.0f;
float newRad =  -newHeading.trueHeading * M_PI / 180.0f;
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
theAnimation.fromValue = [NSNumber numberWithFloat:oldRad];
theAnimation.toValue=[NSNumber numberWithFloat:newRad];
theAnimation.duration = 0.5f;
[compassimage.layer addAnimation:theAnimation forKey:@"animateMyRotation"];
compassimage.transform = CGAffineTransformMakeRotation(newRad);

【问题讨论】:

    标签: ios objective-c ios7 uiimageview cabasicanimation


    【解决方案1】:

    好的,我意识到这是一个 AutoLayout 问题。有趣的是,这个问题从 iOS 6 开始,并延续到 iOS 7。据我所知,它似乎不会影响 iOS 8!

    修复选项:- 1) 添加中心 x & y 约束 或者 2) 禁用自动布局

    两者都产生了预期的结果,尽管我选择了第一!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多