You can rotate a view, by some number of radians, regardless of whether it is less than a full rotation or many multiples of a full rotation, without having to split the rotation into pieces. As an example, the following code will spin a view, once per second, for a specified number of seconds. You can easily modify it to spin a view by a certain number of rotations, or by some number of radians.
This question asks the same thing, although in different words. The answers in that question, as well as in this question should provide a way to animate a UIView (UIImageView is simply a subclass of this) about its center for 360 degrees or more.
How is this answer different from @mahboudz's answer? You will have way cleaner code if most of your functions returns objects instead of just manipulating some objects here and there.
发布评论
评论(5)
您可以将视图旋转一定的弧度,无论它是小于完整旋转还是完整旋转的许多倍,而不必将旋转分割成多个部分。例如,以下代码将每秒旋转一次视图指定的秒数。您可以轻松修改它以将视图旋转一定数量的旋转或一定数量的弧度。
You can rotate a view, by some number of radians, regardless of whether it is less than a full rotation or many multiples of a full rotation, without having to split the rotation into pieces. As an example, the following code will spin a view, once per second, for a specified number of seconds. You can easily modify it to spin a view by a certain number of rotations, or by some number of radians.
根据 mahboudz 的答案,您可以通过设置将其设置为无限旋转:
rotationAnimation.repeatCount = HUGE_VALF;
based on mahboudz's answer, you can set it to infinitely spin by setting:
rotationAnimation.repeatCount = HUGE_VALF;
如果您的意思是“如何使图像遵循圆形路径?”,那么伪代码将是:
If you mean, "How do you make an image follow a circular path?", then the pseudocode would be:
这个问题询问同一件事,尽管用不同的话说。该问题以及此问题中的答案应提供一种使 UIView(UIImageView 只是其子类)绕其中心旋转 360 度或更多的动画的方法。
This question asks the same thing, although in different words. The answers in that question, as well as in this question should provide a way to animate a UIView (UIImageView is simply a subclass of this) about its center for 360 degrees or more.
创建动画
将其添加到视图
这个答案与 @mahboudz 的答案有何不同?如果大多数函数都返回对象而不是仅仅在这里或那里操作一些对象,那么您将拥有更清晰的代码。
Creating the animation
Add it to a view
How is this answer different from @mahboudz's answer? You will have way cleaner code if most of your functions returns objects instead of just manipulating some objects here and there.