I am trying to loop over partial circles to achieve the animation but it only turns 180 degrees, and then starts again from 0 degrees to 180 degrees. So there is an abrupt jump from 180 degrees to 360 degrees. How can I have my circular image object rotate continuously without any jumps? Here is my current code:
UIViewAnimationOptions options = UIViewAnimationOptionCurveLinear|UIViewAnimationOptionRepeat;
[UIView animateWithDuration:ROTATE_ANIMATION_DURATION/2 delay:0 options:options
animations:^{
view.transform = CGAffineTransformRotate(transform, M_PI);}//1st step of animation finished
completion:^(BOOL finished) {
[UIView animateWithDuration:ROTATE_ANIMATION_DURATION/2 delay:0 options:options
animations:^{
view.transform = CGAffineTransformRotate(transform, M_PI);} //2nd step of animation finished
completion:^(BOOL finished) {nil;
}];
Spin UI Object, animation rotate 360 Degree
you’ll need to add the QuartzCore Framework to your project and include the
#import QuartzCore/QuartzCore.h
Add animation for object:
CABasicAnimation *fullRotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
fullRotation.fromValue = [NSNumber numberWithFloat:0];
fullRotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
fullRotation.duration = 6;
fullRotation.repeatCount = 1e100f;
[myview.layer addAnimation:fullRotation forKey:@"360"];
I found some old code that I use to rotate a view 360 degrees, I hope it helps. You'll need to import QuartzCore.
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.zRad"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0];
rotationAnimation.duration = 3;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = INFINITY;
rotationAnimation.timingFunction =
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
[viewToAnimate.layer addAnimation:rotationAnimation forKey:@"transform.rotation.zRad"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With