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 !
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
.
上一篇: bash找到链接到一个然后打印的grep