numist / UIImageView-NDVAnimatedGIFSupport

The dream of the 90s is alive in UIKit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UIImageView+NDVAnimatedGIFSupport

Ever wanted to jam an image brimming with animated GIF goodness into a UIImageView?

Well you're in luck—with this UIImageView category, you can do precicely that!

How Do I Use It?

The UIImageView Category

Got an NSURL? No problem:

NSURL *imageURL = [[NSBundle mainBundle] URLForResource:@"monkey-riding-a-goat" withExtension:@"gif"];
UIImageView *imageView = [[[UIImageView alloc] ndv_initWithAnimatedGIFURL:imageURL] autorelease];

Perhaps you have an NSData? No sweat:

NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImageView *imageView = [[UIImageView alloc] ndv_initWithAnimatedGIFData:imageData];

Now you too can keep the dream of the 90s alive with UIKit!

The NNAnimatedGIFView Class

Know you've got an animated GIF in your NSData, and just want a view that does the Right Thing? Try:

NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
NNAnimatedGIFView *imageView = [[NNAnimatedGIFView alloc] initWithData:imageData];

Not sure if your image is animated or not, and just want a view to display it with? Try:

NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIView *imageView = [NNAnimatedGIFView imageViewForData:imageData];

Anything else?

GIFs are 90s fabulous, but this code is not. It uses ARC and other modern goodness, so you'll want all your project's knobs set for The Future when you put this in.

About

The dream of the 90s is alive in UIKit


Languages

Language:Objective-C 100.0%