When I started programming my app I decided not to use any third party game frameworks (like Cocos2D) but native cocoa tools. That means all the animations in my app are done rather using Core Animation or animating some UIView’s properties.
Everything was all right, the 4 mini-games inside the app started to look like proper games. So like every proper game, the user has to be able to pause it. And no, don’t look at the documentation, there is no [myLayer pauseAnimation] nor [myLayer resumeAnimation].
Lucky me, like any other developer, I found the answer where it should be: stackOverflow.
This is as you see a very short post, as I haven’t solved this problem myself, I just found it. Although, I thought that this snippet might be handy for you as it has been for me.
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
CFTimeInterval pausedTime = [layer timeOffset];
layer.speed = 1.0;
layer.timeOffset = 0.0;
layer.beginTime = 0.0;
CFTimeInterval timeSincePause = [layer convertTime:CACurrentMediaTime() fromLayer:nil] - pausedTime;
layer.beginTime = timeSincePause;
PS: I guess this should work with CAKeyFrameAnimation as well, but I haven’t tried it.