Animated GIF alternative for 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).
开发者_StackOverflowBut, 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?
Thanks.
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/
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
For future references, Eric's answer here is a better way to do it since it uses modern ImageIO.framework and is also available as a category on UIImageView.
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]];
精彩评论