Youaregreat
Youaregreat

Reputation: 69

how to use gif images in UIImageView iOS

i have one gif image file having 4 images , i like to display these images in UIImage view one by one line image.animation . please guide is it possible to display or shoul i use alternat tell me .

thank you .

Upvotes: 1

Views: 11786

Answers (5)

Raphael Schaad
Raphael Schaad

Reputation: 1659

FLAnimatedImage is a performant open source animated GIF engine for iOS:

  • Plays multiple GIFs simultaneously with a playback speed comparable to desktop browsers
  • Honors variable frame delays
  • Behaves gracefully under memory pressure
  • Eliminates delays or blocking during the first playback loop
  • Interprets the frame delays of fast GIFs the same way modern browsers do

It's a well-tested component that I wrote to power all GIFs in Flipboard.

Upvotes: 3

Mannam Brahmaiah
Mannam Brahmaiah

Reputation: 2283

First of all you can add those 4 images in one Plist and do the following code. I hope it will work

    NSDictionary *picturesDictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PhotesArray" ofType:@"plist"]];
NSArray *imageNames = [picturesDictionary objectForKey:@"Photos"];
NSMutableArray *images = [[NSMutableArray alloc] init];
for (int i=0; i<[imageNames count]; i++) {
    [images addObject:[UIImage imageNamed:[imageNames objectAtIndex:i]]];
}
//Normal animation
self.dataImageView.animationImages = images;
self.dataImageView.animationDuration = 3.0;
[self.dataImageView startAnimating];

Upvotes: 0

RameshRajput
RameshRajput

Reputation: 84

it will help you , for gif link..https://github.com/mayoff/uiimage-from-animated-gif more help please feel free to ask

Upvotes: 1

iosLearner
iosLearner

Reputation: 1331

Try like this...

- (void)viewDidLoad {
        [super viewDidLoad];

        NSURL *url = [[NSBundle mainBundle] URLForResource:@"loading" withExtension:@"gif"];
        UIImage *loadingImage = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]];
        self.dataImageView.animationImages = loadingImage.images;
        self.dataImageView.animationDuration = loadingImage.duration;
        self.dataImageView.animationRepeatCount = 1;
        self.dataImageView.image = loadingImage.images.lastObject;
        [self.dataImageView startAnimating];
    }

Upvotes: 0

dhaya
dhaya

Reputation: 1522

yes it possible in iOS,here i enclosed one URL below.please refer this for your concept,even i did it with help of this link.

https://github.com/mayoff/uiimage-from-animated-gif

hope i held you.

Upvotes: 0

Related Questions