【问题标题】:Display gif image without using UIWebview [duplicate]在不使用 UIWebview 的情况下显示 gif 图像 [重复]
【发布时间】:2014-10-07 18:12:06
【问题描述】:

在我的应用程序中,我需要在我的视图上显示 gif 图像,但不要使用 UIWebview 来显示它。那么有什么办法吗?提前致谢!

【问题讨论】:

标签: ios objective-c iphone gif


【解决方案1】:

看看这个

https://github.com/mayoff/uiimage-from-animated-gif

它提供以下类别:

+[UIImage animatedImageWithAnimatedGIFURL:(NSURL *)url]

让你简单地:

#import "UIImage+animatedGIF.h"
UIImage* mygif = [UIImage animatedImageWithAnimatedGIFURL:[NSURL URLWithString:@"http://en.wikipedia.org/wiki/File:Rotating_earth_(large).gif"]];

【讨论】:

    【解决方案2】:

    你可以使用来自 gothub 的这个项目 https://github.com/mayoff/uiimage-from-animated-gif

    例子

    NSURL *url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"gif"];
    self.dataImageView.image = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
    self.urlImageView.image = [UIImage animatedImageWithAnimatedGIFURL:url];
    
    url = [[NSBundle mainBundle] URLForResource:@"variableDuration" withExtension:@"gif"];
    self.variableDurationImageView.image = [UIImage animatedImageWithAnimatedGIFURL:url];
    

    【讨论】:

    • 对好的链接投赞成票,所以只有答案是接受,所以这必须是较早的答案。感谢您的帮助。
    猜你喜欢
    • 2010-11-18
    • 2011-10-06
    • 2018-09-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-23
    • 2023-03-16
    • 2018-03-06
    • 2018-08-13
    相关资源
    最近更新 更多