SwiftGifOrigin 1.7.0

SwiftGifOrigin 1.7.0

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最新发布2019年1月
SPM支持 SPM

Arne Bahlo 维护。



  • Arne Bahlo

SwiftGif Swift 3.0 Carthage 兼容 CocoaPods 许可 MIT 构建状态

一个支持 GIF 的 UIImage 扩展。

Demo gif

用法

// An animated UIImage
let jeremyGif = UIImage.gif(name: "jeremy")

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

// A UIImageView with async loading from asset catalog(from iOS9)
let imageView = UIImageView()
imageView.loadGif(asset: "jeremy")

安装

CocoaPods

使用以下命令安装 CocoaPods:

gem install cocoapods

通过创建 Podfile 将 SwiftGif 集成到您的 Xcode 项目中。

platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'SwiftGifOrigin', '~> 1.7.0'
end

运行 pod install 以构建依赖。

Carthage

使用以下命令通过 Homebrew 安装 Carthage

brew update
brew install carthage

将以下行添加到您的 Cartfile 以添加 SwiftGif

github "bahlo/SwiftGif" ~> 1.7.0

运行 carthage update 以构建框架并将构建的 SwiftGif.framework 拖入您的 Xcode 项目。

如何工作?

很简单,它会做以下事情

  1. 找出每一帧的持续时间
  2. 找出最大公约数
  3. 将帧按照最大公约数添加到数组中
  4. 使用帧创建一个动画的 UIImage

测试

$ xcodebuild \
  -project SwiftGif.xcodeproj \
  -scheme SwiftGif \
  -sdk iphonesimulator \
  -destination "platform=iOS Simulator,name=iPhone 8" \
  build test \
  CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=""

灵感

本项目深受uiimage-from-animated-gif启发。向@mayoff致敬。👍

许可

该仓库采用MIT许可证,更多信息请参阅LICENSE