问题描述
我已将CALayer添加到我的应用的UIView中:
I have added a CALayer to the UIView of my app:
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.35];
[animation setTimingFunction:UIViewAnimationCurveEaseInOut];
animation.type = @"pageCurl";
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 0.58;
[animation setRemovedOnCompletion:NO];
[[self.view layer] addAnimation:animation forKey:@"pageCurlAnimation"];
现在,当用户旋转设备时,图层始终停留在屏幕上的同一位置(在行到主屏幕按钮)。可以旋转动画/图层吗?我尝试过
Now when the user rotates the device, the layer always stays in the same position on the screen (in line to the homescreen button). Is it possible to rotate the animation/layer? I tried
self.view.layer.transform = CGAffineTransformMakeRotation (angle);
但是此代码只是旋转UIView而不是我设置的动画/图层。
but this code just rotates the UIView and not the animation/layer I set.
推荐答案
该错误是因为CALayer的transform属性的类型为CATransform3D,并且您为其提供了CGAffineTransform。使用
CATransform3D CATransform3DMakeRotation(CGFloat角度,CGFloat x,CGFloat y,CGFloat z);而是
。
The error is because the type of the transform property of CALayer is CATransform3D, and you're giving it a CGAffineTransform. UseCATransform3D CATransform3DMakeRotation (CGFloat angle, CGFloat x, CGFloat y, CGFloat z);instead.
这篇关于如何转换(旋转)已经存在的CALayer /动画?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!