How to animate CATransform3D with multiple conversions?

Basically, I rotate the layer around a point like:

CATransform3D transform = CATransform3DIdentity; transform.m34 = 1.0 / -500; transform = CATransform3DTranslate(transform, rotationPoint.x-center.x, rotationPoint.y-center.y, 0.0); transform = CATransform3DRotate(transform, (rotationAngleFor) * M_PI / 180.0f, 0.0, 1.0, 0); transform = CATransform3DTranslate(transform, center.x-rotationPoint.x, center.y-rotationPoint.y, 0.0); 

I also create a layer, add it to a larger layer, and then apply the transform to it:

 [self.layer addSublayer:myLayer]; myLayer.transform = transform; 

How to revive it?

Note. Inserting this into a UIView animation UIView does not work.

+4
source share
1 answer

Edit: Since @DuncanC indicated that my description does not match the actual code.

You can use CABasicAnimation , which is added to the layer as follows.

 CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath: @"transform"]; <here goes your definition of transform> transformAnimation.toValue = [NSValue valueWithCATransform3D:newTransform]; transformAnimation.duration = 10; [self.layer addAnimation:transformAnimation forKey:@"transform"]; 

This animation continuously changes the transform property of the layer from the original value of the transform property of the layer to the newTransform transformation. This change takes 10 seconds.

+8
source

Source: https://habr.com/ru/post/1433035/


All Articles