PDA

View Full Version : rotate UIImageView around a given point




Tex-Twil
Jul 28, 2011, 02:51 PM
Hello,
I have a UIImageView that I rotate around its center:


imageHorizon.transform = CGAffineTransformRotate(imageHorizon.transform, angleToRotate*(CGFloat)(M_PI/180));


but I would like to rotate it around the center of its superview. Is this possible ?

thanks,
Tex



Paul Slocum
Jul 30, 2011, 08:22 PM
From this thread it looks like it might be possible to do what you need:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/4181-rotating-uiimageview-around-arbitrary-point.html

I tried using CGAffineTransformRotate in an OpenGL game-like application and it was too slow, but the speed may not affect your app.

Tex-Twil
Aug 2, 2011, 12:17 AM
From this thread it looks like it might be possible to do what you need:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/4181-rotating-uiimageview-around-arbitrary-point.html

I tried using CGAffineTransformRotate in an OpenGL game-like application and it was too slow, but the speed may not affect your app.

I found a easier solution which is putting the image in a view and rotating the view (around its center). I can move the image within the uiview and it will rotate all the time around the center of the view.