Hi I want to rotate a control on its right bottom point(like a clock needle). I am able to do so with the following code :
self.label.layer.anchorPoint = CGPointMake(1.0, 1.0);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
self.label.transform = CGAffineTransformMakeRotation(M_PI/2);
[UIView commitAnimations];
But the problem here is that my label shifts a bit on the x axis to left and then rotate. I am not getting what’s wrong.. Please help.
Similar post: iPhone, How do I rotate an UIImageView around a point using Core Animation and CATransform3D?
What I do in this situation is move the label over prior to the animation block. For instance, if you are changing your anchor point to CGPoint 1.0,1.0 then simply apply a transform to that label prior to the animation. You can save a reference point in your viewDidLoad to the original location also if you plan on performing multiple transforms. *Code hasn’t actually been compiled but this should give you a good idea.