small medium large xlarge

05 Oct 2009, 01:20
Hughes (4 posts)


I am planning to do an iPhone animation which is composed of 7 pictures, let’s say p1.png, p2.png, …, p7.png. And the animation starts with p1.png, stops on p7.png, and then p7.png remains on the screen. So would anybody please tell me how to program this animation? Thank you in advance.


05 Oct 2009, 10:49
Bill Dudney (916 posts)

Hi Hughes,

This is a very generic question, one that the book was written to answer. Is there something specific that is going wrong, or that you don’t understand. Or are you looking for general getting started advice?

If the later, you can approach it in several ways. I’d start by creating a layer then changing its contents from p1 to p2 etc until you reach p7.

Good luck.

05 Oct 2009, 13:18
Hughes (4 posts)

Hi Bill,

Thank you. I have the following piece of code and it’s working on my application now.

=================================================================== imageArray = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@”p1.png”], [UIImage imageNamed:@”p2.png”], [UIImage imageNamed:@”p3.png”], [UIImage imageNamed:@”p4.png”], [UIImage imageNamed:@”p5.png”], [UIImage imageNamed:@”p6.png”], [UIImage imageNamed:@”p7.png”], nil]; UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(5, 310, 340, 110)]; imageView.animationImages = imageArray; imageView.animationDuration = 3.0; imageView.animationRepeatCount = 1; [imageView startAnimating]; imageView.image = [UIImage imageNamed:@”p7.png”]; [self.view addSubview: imageView]; [imageArray release]; ===================================================================

You must be logged in to comment