How to use UIImageView in iPhone for animation

10 Jul

n this application we will see , how to use UIImagesView to view without using Interface Builder. Basically images are working with an infinite loop . Just have a look.

Step 1: Create a View base application using template. Give the application name “Animation”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: We need to add the resources file called as “1.gif”, “2.gif” , “3.gif”,  ”4.gif”, “5.gif”, “6.gif” into the resource folder. Select resources and add files existing sources.

Step 4: Open the AnimationViewController.m file and make the following changes in the file.

– (void)viewDidLoad {
UIImageView*animationView = [[UIImageView alloc] initWithFrame:self.view.frame];
animationView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@”1.gif”],
[UIImage imageNamed:@”2.gif”],
[UIImage imageNamed:@”3.gif”],
[UIImage imageNamed:@”4.gif”],
[UIImage imageNamed:@”5.gif”],
[UIImage imageNamed:@”6.gif”], nil];

animationView.animationDuration = 1.25;
animationView.animationRepeatCount = 0;
[animationView startAnimating];
[self.view addSubview:animationView];
[animationView release];


Step 5: Now compile and run the application in the Simulator.


You can downloaded SourceCode from here Animation 2


Original Post

Leave a comment

Posted by on July 10, 2011 in iPhone


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: