APNGKit 是一個(gè)用于加載和顯示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()