I have a UIView object. It rotates when I change global variable angle. I have a function that removes this UIView from it's superview and redraws it. I have added a button. When user presses this button I need to launch an animation. In every step I need to change the angle and call my redraw function. So so effect I'm expecting to see is that my view is rotating. here's the code:
-(IBAction)animate:(id)sender
{
NSLog(@"animate: called");
[UIView animateWithDuration:0.7
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^{
angle=angle+5.0;
if (angle>360)
{
angle=angle-360;
}
else if(angle<0)
{
angle=angle+360;
};
NSLog(@"inner angle: %g", angle);
[self transform]; //this is my redraw function. it redraws my view depending on global variable value angle.
}
completion:NULL];
NSLog(@"finalAngle: %g", angle);
}
Why this animation does not working normally?