iOS Swift 如何在我的项目中使用 Gif 文件

标签 ios swift3 uiimage

在我的应用程序中,我需要使用 .gif 并且我确实对其进行了搜索。每个人都要求使用 UIImage.gifImageWithName("funny")UIImage.gifWithName("jeremy") 添加 .gif 文件。但是我在那些 Type 'UIImage' has no member 'gifWithName' 上遇到错误。如何解决这些问题以及如何在我的应用中使用 .gif

最佳答案

https://github.com/bahlo/SwiftGif/tree/master/SwiftGifCommon 下载 UIImage+Gif.swift 文件并放入您的项目中..

// An animated UIImage
let Gif = UIImage.gif(name: "jerry")

// A UIImageView with async loading
let imageView = UIImageView()
imageView.loadGif(name: "tom")]

demo

关于iOS Swift 如何在我的项目中使用 Gif 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43870427/

相关文章:

iOS/MKMapView : If one assigns to the image property of an MKAnnotationView an animated UIImage, 没有动画

ios - 暂停和恢复 AnimateWithDuration 动画 ios

ios - 从 IOS 中的返回键执行按钮单击

swift - 如何提取 zip 文件并在 Swift 的共享扩展中获取提取的组件

ios - 我的应用程序很简单应用程序崩溃了

ios - 使用 resizableImageWithCapInsets 崩溃 :UIEdgeInsetsMake

ios - 为什么我的 UIGraphicsImageRenderer 没有绘图 (iOS 10)?

objective-c - 在 Objective-C 中删除动态创建的对象时,我应该将什么设置为 nil?

ios - 检查 UIAlertController 是否已经呈现的最佳方法是什么?

ios - swift 3 : Can you save the position of a cropped image and access it later when the full image is displayed?