Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to rotate CALayer at one point

Tags:

how to rotate CALayer at one selected point.

like image 356
kiran kumar Avatar asked Oct 13 '10 18:10

kiran kumar


1 Answers

CATransform3D transform = CATransform3DIdentity;
transform = CATransform3DTranslate(transform, rotationPoint.x-center.x, rotationPoint.y-center.y, 0.0);
transform = CATransform3DRotate(transform, rotationAngle, 0.0, 0.0, -1.0);
transform = CATransform3DTranslate(transform, center.x-rotationPoint.x, center.y-rotationPoint.y, 0.0);

Where center is the center of your layer, rotationAngle is in radians (positive is counterclockwise), and rotationPoint is the point about which you wish to rotate. center and rotationPoint are in the coordinate space of the containing view.

like image 163
warrenm Avatar answered Dec 10 '22 02:12

warrenm