What happens if I set a property twice to two different values inside of an animation block? If I execute the following pseudocode:
myView.frame = CGRectMake(0, 0, 50, 50); // state 0
[UIView beginAnimations:@"showBanner" context:NULL];
{
[UIView setAnimationDuration:2];
myView.frame = CGRectMake(0, 20, 50, 50); // state 1
myView.frame = CGRectMake(0, 10, 50, 50); // state 2
}
[UIView commitAnimations];
which of the following results should I get?
- The frame animates from state 0 through state 1 to state 2.
- The frame animates from state 0 directly to state 2, ignoring state 1.
I would expect result #2 to happen because I would think that the state of the properties is recorded when the animation is committed. I’m getting a behavior in my app which seems to indicate that result #1 is happening, hence my question.
Actually the answer is 3. None of the above.
The animation block will only animate the last state change for the property. So in your case the frame will animate from state 1 to state 2.