views:

84

answers:

2

I'm trying to animate a GIF and I hit a roadblock. I have an example of what I'm trying to do that uses the individual frames of the GIF and setting the animationImages property of a UIView. However in my project, the thing I want to animate is drawn using Layers. I'm looking for a quick and easy way to animate the frames without introducing too much complexity. Is there any animationImages equivalent with Layers? Does anybody have any ideas?

A: 

Here you go, enjoy:

http://github.com/jamesu/glgif

Corey Floyd
That's pretty awesome! Still a little removed from what I'm trying to do. I don't have or want a separate UIView. I need to briefly switch on animated frames for a CALayer I suppose I could set a timer and cycle the frames programmatically. I was just wondering if there were somethng similar to an animatedImages property in the CA API.
Cliff
A: 

Another solution:

The contents property of a CALayer is animatable. Meaning you can create a CAKeyFrameAnimation and supply it with an array of images for each frame. You can also set the timing of it.

Note, will likely work better with PNGs

Maybe that helps instead.

Corey Floyd