我在我的应用程序的UIView中添加了一个CALayer:
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而不是我设置的动画/图层。
答案 0 :(得分:4)
错误是因为CALayer的transform属性的类型是CATransform3D,并且你给它一个CGAffineTransform。使用 CATransform3D CATransform3DMakeRotation(CGFloat角,CGFloat x,CGFloat y,CGFloat z); 代替。