【问题标题】:How to get gif asset UIImage如何获取 gif 资产 UIImage
【发布时间】:2016-09-18 21:47:31
【问题描述】:

如何从 *.imageset 文件夹以不同的分辨率将 动画 GIF 图像作为 UIImage 加载,而无需任何额外的 pod?

如果我将我的 GIF 图片放在 *.imageset 文件夹中,它们会在 XCode http://take.ms/7fsCp 中正确显示,但是当我尝试使用 UIImage 加载它时,它会返回 nil

UIImage *image = [UIImage imageNamed: @"help_image"];

如何让它发挥作用?

【问题讨论】:

    标签: ios objective-c uiimage gif animated-gif


    【解决方案1】:

    您可以使用SDWebImage 来执行此操作。

    #import "UIImage+GIF.h"
    
    self.imageViewGif.image= [UIImage sd_animatedGIFNamed:@"help_image"];
    

    希望对你有帮助。

    【讨论】:

    • 我在提问之前已经阅读了这篇文章,并考虑了更简单的解决方案,无需额外的框架。现在使用 SD。谢谢
    【解决方案2】:

    Add animated Gif image in Iphone UIImageView

    检查这个链接你会得到你的答案使用 UIImage 类别你可以得到 exect 输出。

    【讨论】:

      猜你喜欢
      • 2019-11-29
      • 2014-02-24
      • 1970-01-01
      • 1970-01-01
      • 2019-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-07
      相关资源
      最近更新 更多