APNGKit 是一个用于加载和显示APNG图片的高性能框架,它使用 Swift 编写。
加载APNG图片示例代码:
// Load an APNG image from file in main bundle
var image = APNGImage(named: "your_image")
// Or
// Load an APNG image from file at specified path
var path = NSBundle.mainBundle().pathForResource("your_image", ofType: "apng")
if let path = path {
image = APNGImage(contentsOfFile: path)
}
// Or
// Load an APNG image from data
let data: NSData = ... // From disk or network or anywhere else.
image = APNGImage(data: data)
显示APNG图片示例代码:
let image: APNGImage = ... // You already have an APNG image object. let imageView = APNGImageView(image: image) view.addSubview(imageView) //And play the animation: imageView.startAnimating()