Reputation: 203
So, I've searched quite a bit for this and can't seem to find a solution.
This code works:
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationDuration:5];
[c setCenter:CGPointMake(200, 200)];
[UIView commitAnimations];
This code doesn't:
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:c cache:YES];
[UIView setAnimationDuration:5];
[c exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
[UIView commitAnimations];
And I know the call to exchangeSubViewAtIndex is working because if I remove it from the animation block it functions as expected.
Anyone have any insight as to why this transition won't run? Something I need to import?
Upvotes: 1
Views: 820
Reputation: 3200
I’ll quote Apple (again) here:
If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:
- Begin an animation block.
- Set the transition on the container view.
- Remove the subview from the container view.
- Add the new subview to the container view.
- Commit the animation block.
So you probably would like to use removeFromSuperview
& addSubView:
instead of exchanging two subviews if you were using a predefined transition.
Upvotes: 1