Alessandro
Alessandro

Reputation: 4110

Animating a UIImageView with delay

I am animating a UIImageView in this way:

int timerAnimation = 0.0f;

for (UIImageView* img in imageArray) {

timerAnimation = timerAnimation + 1.0f;

[UIView animateWithDuration:1.0f
                      delay:timerAnimation
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^(void) {
                     img.frame = CGRectMake(20, img.frame.origin.y, 710, 60);
                 }
                 completion:NULL];

I want to reduce the delay time, but I noticed that if I put any value inferior than 1.0,

e.g.

timerAnimation + 0.5f;

Then all the objects move at the save time, as if there was no delay. Why is this?

Upvotes: 1

Views: 90

Answers (1)

Tom van Zummeren
Tom van Zummeren

Reputation: 9220

You are using an int!

int timerAnimation = 0.0f;

It should be a float instead:

CGFloat timerAnimation = 0.0f;

An int doesn't support fractions, so you can only add whole numbers to it (1.0) and not halfs (0.5)

Upvotes: 5

Related Questions