I set the animation as follows:

CABasicAnimation *noteAnimation = [CABasicAnimation animation]; noteAnimation.keyPath = @"position.x"; noteAnimation.byValue = [NSNumber numberWithFloat:CGRectGetWidth(self.view.frame) - 50]; noteAnimation.duration = 1.f; noteAnimation.fillMode = kCAFillModeBoth; noteAnimation.removedOnCompletion = NO; noteAnimation.autoreverses = YES; noteAnimation.repeatCount = HUGE; noteAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; [self.greenSquareView.layer addAnimation:noteAnimation forKey:@"noteAnimation"]; 

To pause the live animation, I use:

 CFTimeInterval pausedTime = [view.layer convertTime:CACurrentMediaTime() fromLayer:nil]; view.layer.speed = 0.0; view.layer.timeOffset = pausedTime; 

But in this case, the stop happens with a jerk

jerking

Full project code: BitBucket

  • show how you create the animation. - Max Mikheyenko
  • @MaxMikheyenko added animation creation code to the question (in the comments not very good formatting) - bacc3
  • since you have autoreverse enabled, I will assume that it manages to show the first frame of the return animation, before we stop - Max Mikheyenko
  • In this case, the auto reverse could not affect it, because the autoreverse effect extends to the end of the animation, in my case I try to stop the current animation, i.e. one whose end has not yet come. - bacc3
  • take out in a separate project and put it on look - Max Mikheyenko

0