在iOS 7中旋转CALayer会随机转换图层

时间:2014-09-12 08:04:28

标签: ios rotation calayer

我正在尝试按照给定角度旋转图像层,但它在iOS 7中显示出一种非常奇怪的行为。它在iOS 8中按预期工作,我无法弄清楚我做错了什么。 / p>

这是预期的图像(iOS 8结果)。 (旋转45度)

expected result

这是我从iOS 7获得的。

enter image description here

箭头应该与图像具有相同的中心,但它会移动到意外的位置。

这是我的代码。 (初始平移和锚点是调整旋转中心,因为箭头图像的旋转不应该发生在该图像的实际中心周围 - 即使没有这些线,它在iOS 7中也没有任何区别)

if (CATransform3DIsIdentity(self.compassImageView.layer.transform)) {
    self.compassImageView.layer.transform = CATransform3DTranslate(CATransform3DIdentity, 0, 5, 0);
}
self.compassImageView.layer.anchorPoint = CGPointMake(0.5, 95 / 180.0);

NSString *zRotationKeyPath = @"transform.rotation.z";
[self.compassImageView.layer setValue:@(targetAngle * M_PI / 180.0) forKeyPath:zRotationKeyPath];

谢谢!

0 个答案:

没有答案