png sequence animation on iphone ?

Discussion in 'iOS Programming' started by imaumac, Oct 28, 2008.

  1. imaumac macrumors member

    Oct 15, 2008
    some body toldme to animate some png sequence:
    we can use a timer.

    but i dont know how to do it.
    some one help please.

    or another suggestion to animate 7 small png sequence please ?

    thank a lot !
  2. SqueegyX macrumors regular

    Mar 24, 2008
    Check out the documentation of UIImageView. It has a whole group of method for animating images.
  3. imaumac thread starter macrumors member

    Oct 15, 2008
  4. imaumac thread starter macrumors member

    Oct 15, 2008
    Really thanks, i was looking on documentation how do this.
    and lookinf for UIImageView animation.
    but I dont understand a lot.

    is there a code to copy and paste please.
    I am ashamed to ask, ...realy

    please one more time sorry
    but i realy need this.

    is there most way to learn this on internet website?
    or What is the easier code to learn please ?

    its only 4 small png sequence (loop)

    and I need to animate while you are reading a text please.
    thanks a lot.
    any help are realy welcome.

    i found this URL but i dont know what is the best to learn:
  5. SqueegyX macrumors regular

    Mar 24, 2008
    Lets see. The docs seem pretty clear. I have never done this before but it looks like this is how it works:

    Make a UIImageView in interface builder and link it to an IBOutlet in your view controller.

    imageArray = [NSArray arrayWithObjects:
        [UIImage imageNamed:@"frame1.png"],
        [UIImage imageNamed:@"frame2.png"],
        [UIImage imageNamed:@"frame3.png"],
        [UIImage imageNamed:@"frame4.png"],
    myImageView.animationImages = imageArray;
    myImageView.animationDuration = 0.25 // Seconds
    myImageView.animationRepeatCount = 0 // zero loops for ever
    [myImageView startAnimating];
    Duration and repeat count are not required and have good default values, but that is how you set them.
  6. HughesLin macrumors newbie

    Oct 4, 2009
    what about no looping?

    What about : if I just want the animation runs 1 time then stops (no looping), and the last frame (frame4.png) remains on the screen. How should I do this? Thanks in advance.
  7. Darkroom Guest


    Dec 15, 2006
    Montréal, Canada
    [COLOR="Green"]//your animation method[/COLOR]
    - (void)flashFadeIn
    	[UIView beginAnimations:@"flashFadeIn" context:NULL];
    	[UIView setAnimationDelegate:self];
    	[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
    	[UIView setAnimationBeginsFromCurrentState:currentStateBOOL];
    	[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    	[UIView setAnimationRepeatCount:repeatCount];
    	[UIView setAnimationDuration:kAnimationFlashFadeInDuration];
    		[self.flash setAlpha:1.0];
    	[UIView commitAnimations];
    [COLOR="green"]//your did stop selector[/COLOR]
    - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
    	if (([animationID isEqualToString:@"flashFadeIn"]) && finished)
    		[self flashFadeOut];
    		[COLOR="green"]//or do whatever else you want when the flashFadeIn animation finishes[/COLOR]

Share This Page