简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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