A small UIImage extension with gif support.
// An animated UIImage letjeremyGif=UIImage.gif(name:"jeremy") // A UIImageView with async loading letimageView=UIImageView() imageView.loadGif(name:"jeremy") // A UIImageView with async loading from asset catalog(from iOS9) letimageView=UIImageView() imageView.loadGif(asset:"jeremy")Install CocoaPods with the following command:
gem install cocoapodsIntegrate SwiftGif into your Xcode project by creating a Podfile:
platform:ios,'9.0'use_frameworks!target'<Your Target Name>'dopod'SwiftGifOrigin','~> 1.6.1'endRun pod install to build your dependencies.
Install Carthage with Homebrew using the following command:
brew update brew install carthageAdd the following line to your Cartfile to add SwiftGif:
github "bahlo/SwiftGif" ~> 1.6.1 Run carthage update to build the framework and drag the built SwiftGif.framework into your Xcode project.
Easy, it does the following:
- Find out the duration of every frame
- Find the greatest common divisor
- Add frames accordingly to the greatest common divisor to an array
- Create an animated UIImage with the frames
$ xcodebuild \ -project SwiftGif.xcodeproj \ -scheme SwiftGif \ -sdk iphonesimulator \ -destination "platform=iOS Simulator,name=iPhone 8" \ build test \ CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" This project is heavily inspired by uiimage-from-animated-gif. Kudos to @mayoff. 👍
This repository is licensed under the MIT license, more under LICENSE.
