Skip to content

Commit

Permalink
Portal animation reverses properly
Browse files Browse the repository at this point in the history
A few minor changes:
 + The forward animation uses snapshots. These have to be replaced with the real views when the animation completes
 + The reverse animation snapshots a view which hasn't been added to the hierarchy. This needs to be added in order to snapshot properly (you get unexpected behaviour otherwise)
  • Loading branch information
ColinEberhardt committed Dec 10, 2013
1 parent 14a8cd0 commit 65b7cc7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions AnimationControllers/CEPortalAnimationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ - (void)executeForwardsAnimation:(id<UIViewControllerContextTransitioning>)trans

// remove all the temporary views
if ([transitionContext transitionWasCancelled]) {
[containerView addSubview:fromView];
[self removeOtherViews:fromView];
} else {
// add the real to- view and remove the snapshots
[containerView addSubview:toView];
[self removeOtherViews:toView];
}

Expand All @@ -89,6 +92,10 @@ - (void)executeReverseAnimation:(id<UIViewControllerContextTransitioning>)transi
// Add the from-view to the container
[containerView addSubview:fromView];

// add the to- view and send offscreen (we need to do this in order to allow snapshotting)
toView.frame = CGRectOffset(toView.frame, toView.frame.size.width, 0);
[containerView addSubview:toView];


// Create two-part snapshots of the to- view

Expand Down Expand Up @@ -132,6 +139,7 @@ - (void)executeReverseAnimation:(id<UIViewControllerContextTransitioning>)transi
[self removeOtherViews:fromView];
} else {
[self removeOtherViews:toView];
toView.frame = containerView.bounds;
}

// inform the context of completion
Expand Down

0 comments on commit 65b7cc7

Please sign in to comment.