private void SwapFromViewController(UIViewController fromViewController, UIViewController toViewController) { fromViewController.WillMoveToParentViewController(null); toViewController.View.Frame = SourceViewController.View.Bounds; SourceViewController.AddChildViewController(toViewController); SourceViewController.Transition(fromViewController, toViewController, 0.3, UIViewAnimationOptions.TransitionCrossDissolve, () => { }, (bool finished) => { fromViewController.RemoveFromParentViewController(); toViewController.DidMoveToParentViewController(SourceViewController); var containerViewController = SourceViewController as ITransitioningViewController; if (containerViewController != null) { containerViewController.ViewChanging.TrySetResult(true); } }); }
void AddInitialViewController(UIViewController viewController) { // first run no transition animation SourceViewController.AddChildViewController(viewController); viewController.View.Frame = SourceViewController.View.Bounds; SourceViewController.Add(viewController.View); viewController.DidMoveToParentViewController(SourceViewController); var containerViewController = SourceViewController as ITransitioningViewController; if (containerViewController != null) { containerViewController.ViewChanging.TrySetResult(true); } }
public override void Perform() { var containerView = ((IContainerController)SourceViewController).ContainerView; var previous = SourceViewController.ChildViewControllers.Last(); if (previous != null && previous.GetType() != typeof(TabBarController)) { previous.RemoveFromParentViewController(); previous.View.RemoveFromSuperview(); } SourceViewController.AddChildViewController(DestinationViewController); containerView.AddSubview(DestinationViewController.View); DestinationViewController.DidMoveToParentViewController(SourceViewController); DestinationViewController.View.TranslatesAutoresizingMaskIntoConstraints = false; DestinationViewController.View.LeadingAnchor.ConstraintEqualTo(containerView.LeadingAnchor).Active = true; DestinationViewController.View.TrailingAnchor.ConstraintEqualTo(containerView.TrailingAnchor).Active = true; DestinationViewController.View.TopAnchor.ConstraintEqualTo(containerView.TopAnchor).Active = true; DestinationViewController.View.BottomAnchor.ConstraintEqualTo(containerView.BottomAnchor).Active = true; }