1

How do I get my animation to run again when viewWillAppear or viewDidAppear get called?

This is my animation:

bounceAnimation =[CABasicAnimation animationWithKeyPath:@"transform.scale"];
[bounceAnimation setToValue:[NSNumber numberWithFloat:1.4f]];
bounceAnimation.duration = 1;
bounceAnimation.repeatCount = 100000;
bounceAnimation.autoreverses = YES;
bounceAnimation.fillMode =kCAMediaTimingFunctionEaseInEaseOut;
bounceAnimation.removedOnCompletion = YES;
[startBtn.layer addAnimation:bounceAnimation forKey:@"bounceAnimation"];
Morten Gustafsson
  • 1,869
  • 2
  • 24
  • 34

1 Answers1

1

How are you invoking your animation?

For the moment, I'm thinking you could either

1) put that above code into a method and call that method from viewDidAppear again.

2) or, maybe better... set the removedOnCompletion property for your animation to NO via

bounceAnimation.removedOnCompletion = NO;

and when you are ready to run it again, invoke that same (retained) animation you added previously.

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215