Sunday, February 05, 2012 Login      Search    
People Online People Online:
Visitors Visitors: 76
Members Members: 7
Total Total: 83

Main » Core Animation  » Application Details
For day 2 I picked something that has been popular in the App Store… “Animations”. The first App I did was iFlame which was a simple video of a flame I shot myself. At the time I had not seen a flame or lighter in the App Store and thought it would be cool to have a flame to hold up at a concert...

Animating with the UIImageView

For day 2 I picked something that has been popular in the App Store… “Animations”.  The first App I did was iFlame which was a simple video of a flame I shot myself.  At the time I had not seen a flame or lighter in the App Store and thought it would be cool to have a flame to hold up at a concert.  My first challenge was getting my flame video to repeat without a pause.   Then, I soon saw Crazy Lighter and wondered how they got it working with an infinite loop.  I cannot say this is “the” way that Crazy Lighter works but this will do for us.  Instead of using a video you can use a UIImageView with a sequence of images and just loop them.  The key section of code is below.

       // create the view that will execute our animation
     UIImageView* campFireView = [[UIImageView alloc] initWithFrame:self.view.frame];
     
     // load all the frames of our animation
     campFireView.animationImages = [NSArray arrayWithObjects:   
                                 [UIImage imageNamed:@"campFire01.gif"],
                                 [UIImage imageNamed:@"campFire02.gif"],
                                 [UIImage imageNamed:@"campFire03.gif"],
                                 [UIImage imageNamed:@"campFire04.gif"],
                                 [UIImage imageNamed:@"campFire05.gif"],
                                 [UIImage imageNamed:@"campFire06.gif"],
                                 [UIImage imageNamed:@"campFire07.gif"],
                                 [UIImage imageNamed:@"campFire08.gif"],
                                 [UIImage imageNamed:@"campFire09.gif"],
                                 [UIImage imageNamed:@"campFire10.gif"],
                                 [UIImage imageNamed:@"campFire11.gif"],
                                 [UIImage imageNamed:@"campFire12.gif"],
                                 [UIImage imageNamed:@"campFire13.gif"],
                                 [UIImage imageNamed:@"campFire14.gif"],
                                 [UIImage imageNamed:@"campFire15.gif"],
                                 [UIImage imageNamed:@"campFire16.gif"],
                                 [UIImage imageNamed:@"campFire17.gif"], nil];
     
     // all frames will execute in 1.75 seconds
     campFireView.animationDuration = 1.75;
     // repeat the annimation forever
     campFireView.animationRepeatCount = 0;
     // start animating
     [campFireView startAnimating];
     // add the animation view to the main window
     [self.view addSubview:campFireView];

Read an original article and get a source code from here

Download file here:

There were 16 comments.

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
nIcE
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
nwm: very nice...
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
very good apps...help me a lot...^^
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Good simple clean example
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Good example for begineers
  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
testing purpose
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
jghj
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
nice app
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Good,
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
jsk
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Good
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Amazing!
  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
good
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Good example and clean working.very precise
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
good
  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
good one

Post Comment

Audio Applications Core Animation OpenGL ES Video Quartz Networking Multithreading Security Controls Windows and Views Tables Address Book File Management Database Access Web Applications Games Accelerometer GPS Utility Applications Other  IPhone Development  IPhone Forums  Directory  Exchange Links
Copyright 2007 by The iPhone Developer    Privacy Statement