Reputation: 1118
I have a simple animation that moves a view from one location to another. The animation functions correctly except for the fact that is doesn't follow the duration set in the method declaration...
[UIView beginAnimations:@"listAnimationIn" context:nil];
[UIView animateWithDuration:1.0
delay:1.0
options:UIViewAnimationCurveLinear
animations:^{
lvc.view.frame = CGRectMake(0, 0, 320, 480);
}
completion:nil];
[UIView commitAnimations];
The delay works, but the animation runs FAST no matter what value I put in for duration (I have tried values from 0.5 to 2000). I have also tried a few UIViewAnimationCurve
options and nothing seems to work.
Am I missing something?
Upvotes: 0
Views: 1600
Reputation: 78393
You don't need the -beginAnimations:context:
and the -commitAnimations
messages. That's the old way of doing it, and you shouldn't really mix. Just call the -animateWithDuration:delay:options:animations:completion:
method. Also, if you add a completion block, it will be passed a boolean variable that will tell you if your animation terminated early or ran to completion. This happens if the animation is too slow, or you have competing animations starting on same view hierarchy (which you do have, with the old style begin/commit calls).
Upvotes: 3