如何转换(旋转)已经存在的 CALayer/动画?
我已将 CALayer 添加到我的应用程序的 UIView 中:
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"];
现在,当用户旋转设备时,该层始终保持在屏幕上的相同位置(与主屏幕按钮一致)。是否可以旋转动画/图层?我尝试过
self.view.layer.transform = CGAffineTransformMakeRotation (angle);
,但这段代码只是旋转 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);
but this code just rotates the UIView and not the animation/layer I set.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误是因为 CALayer 的变换属性的类型是 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. Use
CATransform3D CATransform3DMakeRotation (CGFloat angle, CGFloat x, CGFloat y, CGFloat z);
instead.