in iOS, tutorial

Pause and resume CABasicAnimations

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.

PS: I guess this should work with CAKeyFrameAnimation as well, but I haven’t tried it.

Leave a Reply