Skip to content

Instantly share code, notes, and snippets.

@averydev
Last active January 7, 2016 22:08
Show Gist options
  • Save averydev/8535f13c1d29252e72ee to your computer and use it in GitHub Desktop.
Save averydev/8535f13c1d29252e72ee to your computer and use it in GitHub Desktop.
@implementation ELFFadeAndSlidePushAnimator
- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext{
return 0.35;
}
-(void) animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext{
UIView * containerView = [transitionContext containerView];
NSTimeInterval duration = [self transitionDuration:transitionContext];
UIView *toView = [transitionContext viewForKey:UITransitionContextToViewKey];
UIView *fromView = [transitionContext viewForKey:UITransitionContextFromViewKey];
toView.alpha = 0.f;
CGRect toFinalFrame = fromView.frame;
CGRect toStartFrame = fromView.frame;
toStartFrame.origin.x += 200;
CGRect fromFinalFrame = fromView.frame;
fromFinalFrame.origin.x -= 80;
toView.frame = toStartFrame;
[containerView addSubview:toView];
[UIView animateWithDuration:duration animations:^{
toView.alpha = 1.f;
toView.frame = toFinalFrame;
fromView.frame = fromFinalFrame;
fromView.alpha = 0.f;
} completion:^(BOOL finished) {
BOOL cancelled = [transitionContext transitionWasCancelled];
[transitionContext completeTransition:!cancelled];
}];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment