Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATransformLayer doesn't support implicit animation?

Here's my animation code:

CGFloat zDistance = 850;
CGFloat scaleFactor = BACK_COVER_WIDTH / self.transformLayer.bounds.size.width;
CATransform3D rotation = CATransform3DMakeRotation(M_PI, 0.0, 1.0, 0.0);
CATransform3D scale = CATransform3DMakeScale(scaleFactor, scaleFactor, 0.0);
CATransform3D transform = CATransform3DConcat(rotation, scale);
transform.m34 = 1.0 / -zDistance;
CGPoint location = CGPointMake(CGRectGetMidX(self.layer.frame), CGRectGetMidY(self.layer.frame));
[CATransaction begin];
[CATransaction setAnimationDuration:1.0];
self.transformLayer.transform = transform;
self.transformLayer.position = location;
[CATransaction commit];

self.transformLayer is a CATransformLayer with two sublayers, one for the front and one for the back (I'm creating a "flip" effect). However, this code just sets the position and transform without animation. So I thought that maybe transform doesn't support implicit animation, so I took that out and just tried setting the position, but that didn't animate either (and I know for sure that position supports implicit animation).

Am I doing something wrong or does CATransformLayer just not support implicit animation? The documentation does not say anything about it not supporting it, so I'm assuming it does.

EDIT: This is for Mac OS X, not iOS

like image 380
indragie Avatar asked Nov 15 '22 03:11

indragie


1 Answers

I ended up just using explicit animation, but David Duncan's answer here seems like a step in the right direction for anyone else who comes across this issue.

like image 123
indragie Avatar answered Dec 10 '22 13:12

indragie