动画旋转
我正在尝试使用 CATransform3DMakeRotation 对旋转进行动画处理,但问题是一旦动画完成,图像就会返回到其初始位置,即返回到零。 但我想将其保留在完成旋转的位置。 我该怎么做呢?
编辑 我想做的是创建与新 iPhone 相同的指南针。 基本上,位置管理器每隔几秒(或每秒几个)就会给我新的标题。 使用新的标题和时间戳,我试图获得平滑的图像动画,但没有取得任何进展。 似乎唯一有效的方法是直接应用变换,例如,
compassimage.layer.transform = CATransform3DMakeRotation(newHeading.trueHeading *M_PI/180,0,0,1.0):
但这不是动画的......
Possible Duplicate:
Why CAAnimation Rotation is returning to previous state
I'm trying to animate a rotation using CATransform3DMakeRotation, but the problem is once the animation is finished, the image goes back to its initial position, i.e back to zero. But I'd like to keep it where it finished rotating. How would I do that?
edit
What I'm trying to do is to create the same compass which comes with the new iPhone. Basically the locationmanager gives me new headings every few seconds (or several per second). Using the new heading and the timestamp, I was trying to get a smooth animation of the image but not getting anywhere. The only thing which seems to work is applying the transform directly, e.g.
compassimage.layer.transform = CATransform3DMakeRotation(newHeading.trueHeading *M_PI/180,0,0,1.0):
but that's not animated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,回到基础知识,只是尝试将图像旋转 90 度并保持原样。 将以下代码添加到 - (void)viewDidLoad,但即使它旋转,一旦动画完成,它仍然会返回到其初始位置
CATransform3DrotationTransform = CATransform3DMakeRotation(M_PI, 0, 0, 1.0);
Ok, back to basics, just trying to rotate an image by 90 degrees and keeping it there. Added the following code to - (void)viewDidLoad but even though it rotates it still going back to it's initial position once the animation is finished
CATransform3D rotationTransform = CATransform3DMakeRotation(M_PI, 0, 0, 1.0);
您所要做的就是更改该数字,使其为负值。
all you have to do is change the figure so that it is negative.
您应该设置 animation.removedOncompletion 为 NO
You should set the animation.removedOncompletion to NO