CATransform3DRotate和UIImageView [英] CATransform3DRotate and UIImageView

查看:124
本文介绍了CATransform3DRotate和UIImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用此代码制作 UIImage 视图的动画

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)];

我不知道写什么而不是HERE。请问你能帮帮我吗?
非常感谢!

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

推荐答案

CATransform3DRotate()需要作为其第一个参数,应用旋转的变换。如果你想要旋转图层的变换,你可以使用

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)];

这就是说,如果您遇到的问题是该层突然回到起始位置在动画结束时,您需要做的就是将动画的 removedOnCompletion 属性设置为NO,将其 fillMode 属性设置为 kCAFillModeForwards

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.

这篇关于CATransform3DRotate和UIImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆