I noticed that with iMessage, animated gifs can now be sent and displayed. Does this mean that Apple is now supporting the display of animated GIFs in an application, or is the easiest method still to split the image in frames and then sequentially show them? What is the easiest way to display an animated GIF as of iOS 5.1?
Thanks!
Launch the Photos app from your Home screen. Tap Albums along the bottom of the screen. Tap Animated to view your GIFs.
If you are targeting iOS7 and already have the image split into frames you can use animatedImageNamed:duration:
.
Let's say you are animating a spinner. Copy all of your frames into the project and name them as follows:
spinner-1.png
spinner-2.png
spinner-3.png
Then create the image via:
[UIImage animatedImageNamed:@"spinner-" duration:1.0f];
From the docs:
This method loads a series of files by appending a series of numbers to the base file name provided in the name parameter. For example, if the name parameter had ‘image’ as its contents, this method would attempt to load images from files with the names ‘image0’, ‘image1’ and so on all the way up to ‘image1024’. All images included in the animated image should share the same size and scale.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With