Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to animate the CABasicAnimation in background after the home button is pressed?

I'm new in ios development. I'm using wheel images in my project.The animation is working fine in foreground mode. After that I pressed the home button.now i relaunch the app the wheel animation is not working. this is my code:

CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat: 2*M_PI];
animation.duration = 1.0f;
animation.repeatCount = INFINITY;
[imageLeft.layer addAnimation:animation forKey:@"SpinAnimation"];
like image 287
SBM Avatar asked Jun 17 '13 07:06

SBM


1 Answers

Swift 4.2 Updated

Ah I figured it out - use this and all the cases like stopping after going into the background will be fixed.

animation.isRemovedOnCompletion = false
like image 98
Jeffrey Sun Avatar answered Oct 28 '22 00:10

Jeffrey Sun