Ejemplo n.º 1
0
 private void CloseDrawer(IUIViewControllerContextTransitioning transitionContext, UIViewController fromVC, FlyingObjectsContainterViewController toVC)
 {
     if (Direction == DrawerDirection.Left)
     {
         toVC.View.LayoutIfNeeded();
         toVC.ShiftContainerRight(0);
         UIView.Animate(0.25,
                        () =>
         {
             fromVC.View.Frame = new CGRect(-toVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, fromVC.View.Frame.Size.Width, toVC.View.Window.Frame.Size.Height);
             toVC.View.LayoutIfNeeded();
         },
                        () =>
         {
             transitionContext.CompleteTransition(true);
         }
                        );
     }
     else
     {
         toVC.View.LayoutIfNeeded();
         toVC.ShiftContainerRight(0);
         UIView.Animate(0.25,
                        () =>
         {
             fromVC.View.Frame = new CGRect(toVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, fromVC.View.Frame.Size.Width, toVC.View.Window.Frame.Size.Height);
             toVC.View.LayoutIfNeeded();
         },
                        () =>
         {
             fromVC = null;
             transitionContext.CompleteTransition(true);
         });
     }
 }
Ejemplo n.º 2
0
        private void OpenDrawer(IUIViewControllerContextTransitioning transitionContext, UIViewController toVC, FlyingObjectsContainterViewController fromVC)
        {
            transitionContext.ContainerView.AddSubview(toVC.View);
            var container = (fromVC as FlyingObjectsContainterViewController).ContainerNavigationController;
            var height    = container.View.Window.Frame.Height - (container.View.Window.Frame.Height - container.View.Frame.GetMaxY());

            if (Direction == DrawerDirection.Left)
            {
                toVC.View.Frame = new CGRect(-fromVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                fromVC.View.LayoutIfNeeded();
                fromVC.ShiftContainerRight(270);

                UIView.Animate(TransitionDuration(transitionContext),
                               () =>
                {
                    if (fromVC.View.Frame.Size.Width - 50 > MaxX)
                    {
                        MaxX = 270;
                    }
                    toVC.View.Frame = new CGRect(0, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                    fromVC.View.LayoutIfNeeded();
                },
                               () =>
                {
                    transitionContext.CompleteTransition(true);
                }
                               );
            }
            else
            {
                toVC.View.Frame = new CGRect(fromVC.View.Frame.Size.Width, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                fromVC.View.LayoutIfNeeded();
                fromVC.ShiftContainerRight(270);

                UIView.Animate(TransitionDuration(transitionContext),
                               () =>
                {
                    toVC.View.Frame = new CGRect(fromVC.View.Frame.Size.Width - MaxX, UIApplication.SharedApplication.StatusBarFrame.Size.Height, MaxX, height);
                    fromVC.View.LayoutIfNeeded();
                },
                               () =>
                {
                    transitionContext.CompleteTransition(true);
                }
                               );
            }
        }