Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing custom transitions


In this recipe, we will create an app that displays a view controller modally but with our own custom-animated transition.

Getting ready

Create a new Single View Application in Xamarin Studio and name it CustomTransitionApp. Add another view controller to the project and name it ModalController. Finally, we will need a button on each of these controllers.

How to do it...

Perform the following steps:

  1. Add the following classes to the project:

    public class MyTransitionAnimator : UIViewControllerAnimatedTransitioning
    {
      public bool IsPresenting { get; set; }
      public override double TransitionDuration (IUIViewControllerContextTransitioning transitionContext) {
        return 1;
      }
      public override void AnimateTransition (IUIViewControllerContextTransitioning transitionContext) {
        if (this.IsPresenting) {
          UIView containerView = transitionContext.ContainerView;
          UIViewController toViewController = transitionContext.GetViewControllerForKey(UITransitionContext...