CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✗ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Apr 2016 |
| SPMSupports SPM | ✗ |
Maintained by Jiawei Wang.
An animated GIF engine for iOS in Swift with low memory & cpu usage.
let url = NSBundle.mainBundle().URLForResource(“imagename”, withExtension: "gif")!
let imageData = NSData(contentsOfURL:url)
let image = UIImage()
image.AddGifFromData(imageData!)
let gifmanager = JWAnimationManager(memoryLimit:20)
let imageview = UIImageView()
imageview.AddGifImage(image,manager:gifmanager)
imageview.frame = CGRect(x: 0.0, y: 5.0, width: 400.0, height: 200.0)
view.addSubview(imageview)Inital class 'JWAnimationManager' with memory limit. JWAnimationManager will manage all the GIF image views in it.
When adding a new GIF image view to 'JWAnimationManager',it estimate memory usage of new GIF,and add to 'totalGifSize' as a new valuation.When new valuation is greater than memory limit, JWAnimationManager changes all GIF image views to no-cache mode.
ImageView will be suspended if function 'isDisplayedInScreen' returns false. ImageView will be deleted from 'JWAnimationManager' if function 'isDiscarded' returns false.
| CPU Usage[average] | Memory Usage[average]/MB | |
|---|---|---|
| JWAnimatedImage | 6% ~ 14% [8%] | 7.5 ~ 8.4 [8.2] |
| FLAnimatedImage | 8% ~ 24% [11%] | 7.3 ~ ??? [???] |
| CPU Usage[average] | Memory Usage[average]/MB | |
|---|---|---|
| JWAnimatedImage | 31% ~ 44% [38%] | 12.4 ~ 13.4 [12.9] |
| FLAnimatedImage | 36% ~ 62% [54%] | 11.0 ~ 12.4 [11.3] |
| CPU Usage[average] | Memory Usage[average]/MB | |
|---|---|---|
| JWAnimatedImage | 38% ~ 81% [53%] | 59.3 ~ 82.4 [63.3] |
| FLAnimatedImage | 126% ~ 185% [143%] | 58.4 ~ 98.9 [74.2] |
NOTE:
1.Measurement Factors:
Last updated: March 26, 2016
Measurement device: iPhone6 with iOS 9.3
Measurement tool: Profile in Xcode 7.3
Measurement image: See it in repository, all the parameters are default.
Raw data are here.
2.I've discussed the high memory usage of FLAnimatedImage with @mitchellporter and confirmed this problem does exist,as described here.
JWAnimatedImage is released under the MIT license. See LICENSE for details.