Question

How to create a balloon blown animation in iOS?

I'm using this code:

UIImage *image1 = [UIImage imageNamed:@"exp0.png"];
UIImage *image2 = [UIImage imageNamed:@"exp1.png"];


_ImageView.animationImages = [NSArray arrayWithObjects:image1, image2, nil];
[_ImageView setAnimationDuration:0.75f];

[_ImageView startAnimating];

Only one image is animated using this code, so what would I have to do? Have to create a for loop to change image with respect to time interval?

Was it helpful?

Solution

With UIImageView animation, you don't use a for loop. You give the image view an array of images and a duration, and you start it animating. The system takes care of displaying each frame of your animation in sequence.

You could not use a for loop anyway because the for loop would run too quickly. If you want to do timed animation yourself you would need to use a relating timer. You could use NSTimer, but it isn't super-accurate. It would be better to use CADisplayLink. But then you're back to doing what the UIImageView animation methods are doing.

What is the code you posted doing differently than what you want it to do? Your question is not at all clear.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top