kalafun kalafun - 5 months ago 25
iOS Question

ios animation, rotating button, button suddenly changes position

I am trying to implement

animations
in my
application
. I just want to try a simple rotation of a
button
. The button itself is
rotated
, but also it changes its position and the rotation angle is different than the one I want. I have also added the
autoresizesSubwievs = NO;


- (IBAction)rotateView:(id)sender
{
[UIView animateWithDuration:0.6f delay:0.1 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.view.autoresizesSubviews = NO;
[self.buttoner setTransform:CGAffineTransformRotate(self.buttoner.transform, 90.0f)];
} completion:nil];
}


What am I doing wrong? Can you please help me?

EDIT:
I have two buttons, when the first gets pressed, I call the above method ... but this causes to move the first button and then to move the second button and rotate it with inappropriate angle. I dont understand that at all..

Answer

For the angle problem, Instead of passing 90, you should pass the radian value of the angle which is M_PI/2 .

[self.buttoner setTransform:CGAffineTransformRotate(self.buttoner.transform, M_PI/2)];