0

In our iOS app, we want a loading image which is just our logo, animated. I'm wondering what the best practice is to do this? Would it be to use a series of .png images, or one long .png image. I can also thing of using a .gif but the colour quality is not the greatest.

It may also be possible, since the animation is just resizing of certain elements, to do the animation programatically using several UIimages and resizing them, though it may not be as smooth.

Adam M Thompson
  • 438
  • 5
  • 21

1 Answers1

1
UIImage* img1 = [UIImage imageNamed:@"image_1.png"];
UIImage* img2 = [UIImage imageNamed:@"image_2.png"];
UIImage* img3 = [UIImage imageNamed:@"image_3.png"];
UIImage* img4 = [UIImage imageNamed:@"image_4.png"];
UIImage* img5 = [UIImage imageNamed:@"image_5.png"];

NSArray *images = [NSArray arrayWithObjects:img1,img2,img3,img4,img5,nil];

UIImageView* imageView = [[UIImageView alloc] 
         initWithFrame:CGRectMake((self.view.frame.size.width-80)/2, 50, 80.0, 80.0)];

[imageView setAnimationImages:images];
[imageView setAnimationRepeatCount:100];
[imageView setAnimationDuration:3.0];
[imageView startAnimating];
imageView.tag = 100;
[self.view addSubview:imageView];
MD SHAHIDUL ISLAM
  • 14,325
  • 6
  • 82
  • 89
  • Beware, the imageView.animationImages method described above will crash your device at some point if the images are too large or there are too many of them. See this answer for more info about the memory use issue and how to implement a much better solution http://stackoverflow.com/questions/8112698/how-to-do-animations-using-images-efficiently-in-ios/17129053#17129053 – MoDJ Nov 28 '14 at 10:03