繁体   English   中英

如何转换(旋转)已存在的CALayer /动画?

[英]How to transform (rotate) a already exist CALayer/animation?

我在我的应用程序的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而不是我设置的动画/图层。

错误是因为CALayer的transform属性的类型是CATransform3D,并且你给它一个CGAffineTransform。 使用CATransform3D CATransform3DMakeRotation(CGFloat角度,CGFloat x,CGFloat y,CGFloat z); 代替。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM