Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATransform3DRotate and UIImageView

I'm animating an UIImage view with this code

CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.duration = 1;
animation.toValue = [NSNumber numberWithFloat:M_PI];
animation.fromValue = [NSNumber numberWithInt:0];
[square.layer addAnimation:animation forKey:@"rotation"];

All works fine but my array take his original position at the end of animation. I looked into the layer properties and found :

[square.layer setTransform:CATransform3DRotate(HERE, -M_PI, 0, 0, 0)];

And I don't know what to write instead of "HERE". Could you help me please? Thanks a lot !

like image 201
Pierre Avatar asked Jul 20 '10 23:07

Pierre


1 Answers

CATransform3DRotate() takes as its first parameter a transform to apply a rotation to. If you were looking to rotate the transform of your layer, you would use

[square.layer setTransform:CATransform3DRotate(square.layer.transform, -M_PI, 0, 0, 0)];

That said,if the problem that you are having is that the layer jerks back to the starting position at the end of the animation, all you need to do is set the animation's removedOnCompletion property to NO and its fillMode property to kCAFillModeForwards.

like image 156
Brad Larson Avatar answered Nov 02 '22 22:11

Brad Larson