Skip to content

Instantly share code, notes, and snippets.

@olexale
Created September 1, 2017 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olexale/9600037966a4c5f337ee42449eac1b6c to your computer and use it in GitHub Desktop.
Save olexale/9600037966a4c5f337ee42449eac1b6c to your computer and use it in GitHub Desktop.
public class AnimationNavigationControllerDelegate : UINavigationControllerDelegate
{
private TransitionAnimator _animator = new TransitionAnimator();
private int _id;
public override IUIViewControllerAnimatedTransitioning GetAnimationControllerForOperation(UINavigationController navigationController, UINavigationControllerOperation operation, UIViewController fromViewController, UIViewController toViewController)
{
if (operation == UINavigationControllerOperation.Push)
{
var image = fromViewController.View.ViewWithTag(_id);
var convertedFrame = image.ConvertRectToView(image.Bounds, fromViewController.View);
_animator.ThumbnailFrame = convertedFrame;
}
_animator.Operation = operation;
return _animator;
}
internal void SetTransitionId(int id)
{
_id = id;
}
}
public class AnimationNavigationRenderer : Xamarin.Forms.Platform.iOS.NavigationRenderer
{
private AnimationNavigationControllerDelegate _delegate;
public override void ViewDidLoad()
{
base.ViewDidLoad();
_delegate = new AnimationNavigationControllerDelegate();
Delegate = _delegate;
MessagingCenter.Subscribe<object, int>(this, "TransitionId", (sender, arg) =>
{
_delegate.SetTransitionId(arg);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment