0
votes

I need to display an animation in which the frames for the animation should be displayed for different durations. This could be easily solved if the UIImageView supported animated GIFs, but it doesn't.

What I want would look something like this:

  1. Show MyImage01.png for 2 seconds.
  2. Show MyImage02.png for 0.5 seconds.
  3. Show MyImage03.png for 1 second.
  4. Loop, start from step 1.

I don't see any way to set a different duration for each frame when using setAnimationImages: with the UIImageView.

Does anyone know how this can be achived?

Of course, one way to achieve this would be to set the animation duration to 0.25 seconds and show the same image several times in a row but this does not really seem like an ideal way of achieving this.

1
Other than switching images manually (timers/async blocks/gcd etc) or repeating the image in animationImages array as you suggested - you could look into this: github.com/ondalabs/OLImageView . I never used it though.Mayjak
@Estarriol That's how I ended up doing it. You should leave that as an answer so I can accept it :-) Thank you.simonbs
Be aware that the GIF decoder approach linked here can consume all app memory and cause a crash if the GIF image is too big or contains too many frames. My answer to this other question describes an approach that does not have this problem: stackoverflow.com/questions/8825550/…MoDJ

1 Answers

1
votes

Check out:

http://github.com/ondalabs/OLImageView

NOTE: I never used this component. For a good source of custom controls see http://www.cocoacontrols.com/

Glad I could help :-)