Skip to content

Instantly share code, notes, and snippets.

@olexale
Created September 1, 2017 14:56
Show Gist options
  • Save olexale/adcfe6c530b664b0e143b7a91dd99914 to your computer and use it in GitHub Desktop.
Save olexale/adcfe6c530b664b0e143b7a91dd99914 to your computer and use it in GitHub Desktop.
public class TransitionAnimator : UIViewControllerAnimatedTransitioning
{
private const double _duration = 0.5;
public override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext)
{
var containerView = transitionContext.ContainerView;
var toView = transitionContext.GetViewFor(UITransitionContext.ToViewKey);
containerView.AddSubview(toView);
toView.Alpha = 0;
UIView.Animate(_duration, () =>
{
toView.Alpha = 1;
}, () =>
{
transitionContext.CompleteTransition(true);
});
}
public override double TransitionDuration(IUIViewControllerContextTransitioning transitionContext)
{
return _duration;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment