I have this code to move a view.
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
theAnimation.duration=1;
theAnimation.repeatCount=1;
theAnimation.autoreverses=NO;
theAnimation.fromValue=[NSNumber numberWithFloat:0];
theAnimation.toValue=[NSNumber numberWithFloat:-60];
[view.layer addAnimation:theAnimation forKey:@"animateLayer"];
The problem is: The actual coordinates of the view get reseted after the animation has finished. Is it possible that the view remains at the new coordinates after the animation has finished?
Thanks.
In addition to attaching an animation that animates the property, you have to actually set the property to its final value. Crazy, isn't it? Try doing this before you add the animation:
[view.layer setValue:[NSNumber numberWithFloat:-60] forKey:@"transform.translation.x"];
I strongly recommend watching the WWDC 2011 video "Core Animation Essentials". It explains this, and covers a lot of useful information for anyone using Core Animation. You can find it here: https://developer.apple.com/videos/wwdc/2011/