I am trying to create an animation using a UIImageView with an array if images. It works great, except that I need a different delay between some of the frames. In an animat
You have to use different UIImageView to get this working. Try this application page. Might be helpful for you. Link: http://www.raywenderlich.com/2454/how-to-use-uiview-animation-tutorial
It may seem hacky, but:
From UIImageView
documentation:
animationImages
An array of
UIImage
objects to use for an animation.@property(nonatomic, copy) NSArray *animationImages
Discussion
The array must contain
UIImage
objects. You may use the same image object more than once in the array. Setting this property to a value other thannil
hides the image represented by theimage
property. The value of this property isnil
by default.
So you need to add your UIImage
several times to the array for a delay.
UIImageView
does not support a different delay between different images. You will have to use multiple UIImageView
s and manage the transition between them manually if you want to have different delays between frames.
Another approach would be to use a UIWebView which is sized exactly to fit a .gif
image that has the delay settings you want.
If you would like to try my animation library in your iOS app, it offers a complete solution to this problem. For example, you could take a look at the APNG app, it is a free app in the iTunes store that displays animated APNG files. This app was created using my AVAnimator library which contains APNG and GIF decoding support. The APNG format works just like a GIF in the sense that each frame can have a delay time, you would use existing software to create the APNG in this case. But, it is easier to just encode a new .mvid file (this is a custom video file format) from a series of PNG imags. To create a longer delay, you simply repeat frames that do not change in the input PNG image series. Either approach could be used to create an input movie that could display with a variable amount of time in between specific frames (the overall FPS would be the same, but specific frames can simply repeat so that they do not change for say N frames in a row). You can also implement specific user interactions like starting an animation, pausing on a specific frame, and then starting again from that same frame.