Alternativa GIF animado para iOS

"Back in the day" animated GIFs were ubiquitous online.

They were simple to use - just pop em' in wherever you want an animated image.

I'd like to display an animated image within an iOS application (for example, a graphic illustrating a letter being opened from an envelope).

But, I'm not sure how to go about this.

Obviously I don't want to use an animated GIF.

A video of some sort seems like it might be the preferred solution. But, what about transparency? Also, what about the retina display?

Gracias.

preguntado el 28 de agosto de 11 a las 03:08

Check native methods for [iOS7+][1] [1]: stackoverflow.com/a/21911723/2064576 -

4 Respuestas

Here is a tutorial on animating UIImage in the iPhone SDK:

http://www.icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/

Respondido 28 ago 11, 07:08

+1 for the interesting suggestion. I can easily see how I might use this approach to animate an image using PNG "frames". Although, I'm a little surprised this is the preferred approach. - Steve

@Steve: It is the preferred approach; in fact, it's the only current non-manual non-video approach. Works well for smallish animations with a small number of frames, which is basically the animated-GIF use case (It doesn't scale especially well to large views with lots of frames.) - Ben Zotto

I've found another page describing the same approach. Maybe it will be useful: Making GIF animating on iOS. - Gengis

See what I found out about showing animated gif in iOS. iosnotestoremember.blogspot.com/2013/01/… I hope this helps. - Glenn S

Flipboard just released their GIF library which is very performant and is used by several popular apps like Flipboard, Dropbox, Medium etc:

https://github.com/Flipboard/FLAnimatedImage

respondido 17 nov., 14:09

For future references, Eric's answer aquí is a better way to do it since it uses modern ImageIO.framework and is also available as a category on UIImageView.

contestado el 23 de mayo de 17 a las 13:05

Well, use of ImageIO is better that other approaches. But, that code will still consume all memory when running it on a GIF with more than just 1 or 2 frames of image data. The real solution is to decode ahead of time and cache the decoded results on disk and not in memory. - MoDJ

You can use UIWebView to load html Page with in Bundle. GO TO File > New>Others > Empty > Enter File Name with Extension

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
     <title>QUALITY PLACEMENTS</title>

</head>
<body>
<div style="word-wrap: break-word !important; width: 300px;">
    <img width="100%" src="Surprice-0.gif"/>
   </div></body></html> 
    //IOS CODE 
     UIWebView* mywebview=[[UIWebView alloc]initWithFrame:CGRectMake(5, 50, 300, 300)];
            mywebview.scalesPageToFit = NO;
            mywebview.scrollView.hidden = NO;
            [mywebview setMultipleTouchEnabled:YES];
            NSURL* url=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"greeting" ofType:@"html"]];
            [mywebview loadRequest:[NSURLRequest requestWithURL:url]];

Respondido 16 Oct 14, 11:10

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.