BerryPlant
参考
APNG - https://en.wikipedia.org/wiki/APNG#History PNG - https://en.wikipedia.org/wiki/Portable_Network_Graphics
简书文章
https://www.jianshu.com/p/b83ec03ff41c
Swift 图片库,用于 iOS 上显示/解码 WebP, APNG, GIF, PNG, JPG 等格式
一个用于 Swift 的解码和显示 WEBP, APNG, PNG, GIF, JPG 等更多格式图片的工具包
在异步线程上解码图片,并在 runloop 空闲时进行渲染。
在子线程上解码图片,并在 Runloop 空闲时显示图片。
未来
解码并显示WEBP, APNG, GIF, PNG等格式
解码WEBP, APNG, GIF, PNG等更多格式的图片
使用方法
self.imageView = BerryAnimateImage(data, frame: CGRect(x: 0, y: 200, width: self.view.frame.size.width, height: 300), cache: BerryAnimateImage.Policy.noCache)
self.view.addSubview(self.imageView)
self.imageView.contentMode = .scaleAspectFit
self.imageView.animationRepeatCount = 0
动画控制
self.imageView.startAnimating()
self.imageView.stopAnimating()
获取真实格式
static public func getImageFormat(_ data: Data) -> BerryImageFormat
查找图像解码器
public func FindImageDecoder(with data: Data) -> BerryImageProvider
示例
要运行示例项目,请克隆仓库,然后首先从示例目录运行 pod install
。
安装
Berry 通过 CocoaPods 提供。要安装它,请将以下行添加到您的 Podfile 中
不要使用 'use_frameworks!'}
pod 'Berry'
添加修复代码}
post_install do |installer|
FixBerryUmbrella()
end
def FixBerryUmbrella
berry_unbrella_file_path = (Dir::pwd + '/Pods/Headers/Public/BerryPlant/BerryPlant-umbrella.h')
File.open(berry_unbrella_file_path,"r:utf-8") do |lines|
buffer = lines.read
buffer = buffer.gsub("decode.h","WebP/decode.h")
buffer = buffer.gsub("encode.h","WebP/encode.h")
buffer = buffer.gsub("types.h","WebP/types.h")
File.open(berry_unbrella_file_path,"w"){|l|
l.write(buffer)
}
end
end
作者}
czqasn, [email protected]
许可证}
Berry 项目可使用 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。