适用于 iOS 的动画 GIF 替代品

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7218889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 21:16:37  来源:igfitidea点击:

Animated GIF alternative for iOS

iphoneobjective-cios

提问by Steve

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

“回到过去”动画 GIF 在网上无处不在。

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).

我想在 iOS 应用程序中显示动画图像(例如,说明从信封中打开一封信的图形)。

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

但是,我不知道该怎么做。

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

显然我不想使用动画 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.

谢谢。

回答by Dair

回答by Chintan Patel

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

Flipboard 刚刚发布了他们的 GIF 库,它的性能非常好,被 Flipboard、Dropbox、Medium 等几个流行的应用程序使用:

https://github.com/Flipboard/FLAnimatedImage

https://github.com/Flipboard/FLAnimatedImage

回答by Chintan Patel

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

对于未来的参考,Eric在这里的回答是一种更好的方法,因为它使用现代 ImageIO.framework 并且也可作为 UIImageView 上的一个类别。

回答by Baljeet Singh

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

您可以使用 UIWebView 在 Bundle 中加载 html 页面。转到文件>新建>其他>空>输入带扩展名的文件名

<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]];