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!
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!
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];
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.