public async Task <bool> CloseDrawerAsync() { TapGestureRecognizer.Enabled = false; var finished = await UIView.AnimateNotifyAsync(0.2, () => { TopView.Frame = TopViewFrame; }); DrawerTransitioning?.Invoke(this, new DrawerTransitioningEventArgs(DrawerTransitioningState.Closed)); updateStatusBarAppearance(); return(finished); }
public async override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext) { UIViewController fromVC = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey); UIView fromView = fromVC.View; UIViewController toVC = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey); UIView toView = toVC.View; UIView containerView = transitionContext.ContainerView; if (IsPresentation) { containerView.AddSubview(toView); } UIViewController animatingVC = IsPresentation ? toVC : fromVC; UIView animatingView = animatingVC.View; CGRect appearedFrame = transitionContext.GetFinalFrameForViewController(animatingVC); CGRect dismissedFrame = appearedFrame; CGPoint targetLacation = dismissedFrame.Location; targetLacation.X += dismissedFrame.Size.Width; dismissedFrame.Location = targetLacation; CGRect initialFrame = IsPresentation ? dismissedFrame : appearedFrame; CGRect finalFrame = IsPresentation ? appearedFrame : dismissedFrame; animatingView.Frame = initialFrame; UIViewAnimationOptions opt = UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.BeginFromCurrentState; await UIView.AnimateNotifyAsync(TransitionDuration (transitionContext), 0, 300, 5, opt, () => { animatingView.Frame = finalFrame; }); if (!IsPresentation) { fromView.RemoveFromSuperview(); } transitionContext.CompleteTransition(true); }
public async override void AnimateTransition(IUIViewControllerContextTransitioning transitionContext) { UIViewController fromVC = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey); UIView fromView = fromVC.View; UIViewController toVC = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey); UIView toView = toVC.View; UIView containerView = transitionContext.ContainerView; if (IsPresentation) { containerView.AddSubview(toView); } UIViewController animatingVC = IsPresentation? toVC : fromVC; UIView animatingView = animatingVC.View; animatingView.Frame = transitionContext.GetFinalFrameForViewController(animatingVC); CGAffineTransform presentedTransform = CGAffineTransform.MakeIdentity(); CGAffineTransform dismissedTransform = CGAffineTransform.MakeScale(0.001f, 0.001f) * CGAffineTransform.MakeRotation(8 * (float)Math.PI); animatingView.Transform = IsPresentation ? dismissedTransform : presentedTransform; var opt = UIViewAnimationOptions.AllowUserInteraction | UIViewAnimationOptions.BeginFromCurrentState; await UIView.AnimateNotifyAsync(TransitionDuration (transitionContext), 0, 300, 5, opt, () => { animatingView.Transform = IsPresentation ? presentedTransform : dismissedTransform; }); animatingView.Transform = CGAffineTransform.MakeIdentity(); if (!IsPresentation) { fromView.RemoveFromSuperview(); } transitionContext.CompleteTransition(true); }
public async Task ReplaceViewControllerAsync(UIViewController newViewController, ITransitionAnimation transition) { var oldViewController = TopViewController; oldViewController?.WillMoveToParentViewController(null); AddChildViewController(newViewController); transition.WillTransition(this, newViewController); View.AddSubview(newViewController.View); await UIView.AnimateNotifyAsync(transition.Duration, 0.0f, transition.SpringDampingRatio, transition.InitialSprintVelocity, UIViewAnimationOptions.CurveEaseInOut, () => transition.Transition(this, oldViewController, newViewController)); transition.DidTransition(this, oldViewController, newViewController); oldViewController?.View.RemoveFromSuperview(); oldViewController?.RemoveFromParentViewController(); newViewController.DidMoveToParentViewController(this); TopViewController = newViewController; }