# SwiftGif [![Swift 3.0](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift/) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/SwiftGifOrigin.svg)](http://cocoadocs.org/docsets/SwiftGifOrigin) [![License MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://github.com/Carthage/Carthage) [![Build Status](https://travis-ci.org/bahlo/SwiftGif.svg?branch=master)](https://travis-ci.org/bahlo/SwiftGif)
A small `UIImage` extension with gif support.
![Demo gif](demo.gif)
## Usage
```swift
// 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")
```
## Installation
### CocoaPods
Install [CocoaPods](http://cocoapods.org) with the following command:
```bash
gem install cocoapods
```
Integrate SwiftGif into your Xcode project by creating a `Podfile`:
```ruby
platform :ios, '9.0'
use_frameworks!
target '<Your Target Name>' do
pod 'SwiftGifOrigin', '~> 1.7.0'
end
```
Run `pod install` to build your dependencies.
### Carthage
Install [Carthage](https://github.com/Carthage/Carthage) with
[Homebrew](http://brew.sh/) using the following command:
```bash
brew update
brew install carthage
```
Add the following line to your `Cartfile` to add SwiftGif:
```ogdl
github "bahlo/SwiftGif" ~> 1.7.0
```
Run `carthage update` to build the framework and drag the built
`SwiftGif.framework` into your Xcode project.
## How does it work?
Easy, it does the following:
1. Find out the duration of every frame
2. Find the greatest common divisor
3. Add frames accordingly to the greatest common divisor to an array
4. Create an animated UIImage with the frames
## Testing
```
$ xcodebuild \
-project SwiftGif.xcodeproj \
-scheme SwiftGif \
-sdk iphonesimulator \
-destination "platform=iOS Simulator,name=iPhone 8" \
build test \
CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY=""
```
# Inspiration
This project is heavily inspired by [uiimage-from-animated-gif](https://github.com/mayoff/uiimage-from-animated-gif).
Kudos to [@mayoff](https://github.com/mayoff). :thumbsup:
## License
This repository is licensed under the MIT license, more under
[LICENSE](LICENSE).
没有合适的资源?快使用搜索试试~ 我知道了~
iOS-多媒体-播放Gif动画-5SwiftGif
共53个文件
plist:10个
swift:5个
xcfilelist:4个
需积分: 5 0 下载量 127 浏览量
2023-05-20
19:47:03
上传
评论
收藏 2.06MB ZIP 举报
温馨提示
iOS_多媒体_播放Gif动画_5SwiftGif
资源推荐
资源详情
资源评论
收起资源包目录
iOS_多媒体_播放Gif动画_5SwiftGif.zip (53个子文件)
iOS_多媒体_播放Gif动画_5SwiftGif
.DS_Store 8KB
DemoApp.xcworkspace
xcshareddata
swiftpm
configuration
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 225B
xcuserdata
edy.xcuserdatad
UserInterfaceState.xcuserstate 26KB
fazhanli.xcuserdatad
UserInterfaceState.xcuserstate 20KB
Podfile 139B
DemoApp.xcodeproj
project.pbxproj 17KB
xcuserdata
edy.xcuserdatad
xcschemes
xcschememanagement.plist 342B
fazhanli.xcuserdatad
xcschemes
xcschememanagement.plist 342B
project.xcworkspace
xcshareddata
IDEWorkspaceChecks.plist 238B
contents.xcworkspacedata 135B
xcuserdata
fazhanli.xcuserdatad
UserInterfaceState.xcuserstate 10KB
DemoApp
Base.lproj
Main.storyboard 2KB
LaunchScreen.storyboard 2KB
fire.gif 1.99MB
SceneDelegate.swift 2KB
AppDelegate.swift 1KB
ViewController.swift 567B
Info.plist 2KB
ContentView.swift 328B
Assets.xcassets
Contents.json 63B
AppIcon.appiconset
Contents.json 2KB
AccentColor.colorset
Contents.json 123B
Pods
Pods.xcodeproj
project.pbxproj 26KB
xcuserdata
edy.xcuserdatad
xcschemes
xcschememanagement.plist 463B
fazhanli.xcuserdatad
xcschemes
Pods-DemoApp.xcscheme 2KB
xcschememanagement.plist 558B
SwiftGifOrigin.xcscheme 2KB
.DS_Store 6KB
SwiftGifOrigin
SwiftGif
LICENSE 1KB
README.md 2KB
SwiftGifCommon
UIImage+Gif.swift 6KB
Manifest.lock 297B
Local Podspecs
Headers
Target Support Files
SwiftGifOrigin
SwiftGifOrigin.modulemap 118B
SwiftGifOrigin-dummy.m 132B
SwiftGifOrigin-prefix.pch 195B
SwiftGifOrigin-umbrella.h 320B
SwiftGifOrigin-Info.plist 828B
SwiftGifOrigin.xcconfig 465B
Pods-DemoApp
Pods-DemoApp-frameworks.sh 8KB
Pods-DemoApp-frameworks-Release-output-files.xcfilelist 70B
Pods-DemoApp-acknowledgements.plist 2KB
Pods-DemoApp-dummy.m 128B
Pods-DemoApp-frameworks-Release-input-files.xcfilelist 135B
Pods-DemoApp-Info.plist 828B
Pods-DemoApp-frameworks-Debug-input-files.xcfilelist 135B
Pods-DemoApp.modulemap 114B
Pods-DemoApp-frameworks-Debug-output-files.xcfilelist 70B
Pods-DemoApp-acknowledgements.markdown 1KB
Pods-DemoApp.debug.xcconfig 689B
Pods-DemoApp-umbrella.h 316B
Pods-DemoApp.release.xcconfig 689B
Podfile.lock 297B
共 53 条
- 1
资源评论
GotoLevel
- 粉丝: 23
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功