0

I've got a UIView and I'm adding one of two subviews to it. Subview 1 is shown if event 1 comes in. Subview 2 is shown is event 2 comes in.

So, the following works (in pseudocode):

on_event1: add subview 1 and remove subview 2
on_event2: add subview 2 and remove subview 1

Now, I want to add a transition animation, crossfading between the two views by changing the alpha.

My problem is that if animation for event 1 is in progress and event 2 arrives, I cannot cancel the current animation and start the next. What I'd like to do is stop the current animation in its tracks and start the next one immediately.

How do I do this or the closest alternative to it?

puot
  • 161
  • 1
  • 7

2 Answers2

0

This question addresses a common way of stopping animation part way through:

Cancel a UIView animation?

Community
  • 1
  • 1
occulus
  • 16,959
  • 6
  • 53
  • 76
  • It talks about setAnimationBeginsFromCurrentState. Can this be done when using blocks? – puot Mar 01 '11 at 22:48
0
[UIView transitionFromView:subview1 toView:subview2 duration:0.75 options:UIViewAnimationOptionBeginsFromCurrentState completion:^(BOOL finished) {}];
Mark Adams
  • 30,776
  • 11
  • 77
  • 77