iOS CABasicAnimation animationWithKeyPath:@“transform.rotation”wobble
问题描述:
我有以下代码来旋转指南针。此代码在iPhone 6和iPhone 5上的iOS 8上均可正常工作。iOS CABasicAnimation animationWithKeyPath:@“transform.rotation”wobble
但是,在iOS 7.1.2上使用iPhone 5S尝试此操作时,图像偏离了Z轴,看起来随着它旋转而摆动/浮动。
正如我所说的,这种情况不会发生在iPhone 5或6,这两者都运行iOS 8
谁能提供任何意见?
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);
答
好吧,我意识到这是一个AutoLayout问题。有趣的是,这个问题从iOS 6开始,并继续发展到iOS 7.它看起来不会影响我所看到的iOS 8!
修复的选择: - 1)添加中心x &Ÿ约束 或 2)禁用自动版式
两者产生期望的结果,但我选择了1号!