iosapng

APNG inside iOS app


I'm probably going to get flamed for this.

I am wondering if anyone know of any way to load APNG (animated PNG) inside an iPhone app?

I'm not talking about multiple PNG image added as an NSArray of UIImages to a UIImageView. I already can do this method but this requires multiple PNG images.

I'm talking about a special PNG format called APNG (http://en.wikipedia.org/wiki/APNG) that only contains 1 PNG file but has animation meta data.

I've found this library called AVAnimator: http://www.modejong.com/AVAnimator/index.html which supposedly can load APNG format but the licence cost $475 USD and the library appears to be from a few years ago (iOS 4).

I also read that Apple iOS 8 Safari as well as Yosemite Safari has built in support for APNG.

I really don't want to resort to using a UIWebView just to display an APNG file. It works, I've tested it but I don't think that's ideal.

I was hoping there is some undiscovered new iOS SDK that lets us load APNG into the app that I'm not aware of and maybe you guys might know.

How does the Line app (http://line.me/en/) do it ? They seem to have animated PNGs for their "stickers".


Solution

  • I just released a framework to load and display APNG files for iOS.

    You could just load an APNG image with the same pattern of UIImage and UIImageView like this by using it:

    let image = APNGImage(name: "your_apng_image")
    let imageView = APNGImageView(image: image)
    
    imageView.startAnimating()
    
    view.addSubview(imageView)
    

    For more information, you can find it here: https://github.com/onevcat/APNGKit