开发者

How to rotate a UIImageView

I have a UIImageView that is an image of the star. The problem is I want the star to rotate when I move it. How can I rotate a UIImageView to make it look like it is spinning for 3 seconds. I want it to spin 7开发者_开发问答20 degrees.


For a very simple approach, you can use

imageView.transform = CGAffineTransformMakeRotation(radianRotation);

where radianRotation is a float, e.g. 4*pi for 720 degrees. You can play with basic animations and changing the rotation however you like.

However, if you want a more sophisticated solution, then I highly recommend you look at the answers to this related post: how to rotate UIIMageVIew with fix point?

Also, see the myriad related posts linked on the right hand side of your screen. Many have all the code you need (barring going around in a circle twice).


You can also use

[imageView layer].transform = CATransform3DMakeRotation(variables);


For your commodity, additionally to PengOne's answer you can use M_PI, M_PI_2, M_PI_4 constants that are available in math.h.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜