CATransform3DRotate and UIImageView

烈酒焚心 提交于 2019-12-10 03:59:47

问题


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 !


回答1:


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.



来源:https://stackoverflow.com/questions/3295114/catransform3drotate-and-uiimageview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!