How to animate a series of images in iphone? A simple Example.

By | April 12, 2012

The following code shows animation of 5 images.

	NSArray *images = [NSArray arrayWithObjects:
	[UIImage imageNamed:@”pic1.jpeg”],
	[UIImage imageNamed:@”pic2.jpeg”],
	[UIImage imageNamed:@”pic3.jpg”],
	[UIImage imageNamed:@”pic4.jpeg”],
	[UIImage imageNamed:@”pic5.jpeg”],
	CGRect frame = CGRectMake(0,0,320,460);
	UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
	imageView.animationImages = images;
	imageView.contentMode = UIViewContentModeScaleAspectFit;
	imageView.animationDuration = 3;
	imageView.animationRepeatCount = 0;
	[imageView startAnimating];
	[self.view addSubview:imageView];
	[imageView release];
	[super viewDidLoad];

Leave a Reply

Your email address will not be published. Required fields are marked *