public override void ViewDidLoad() { base.ViewDidLoad(); MainViewController = (NavigationViewController)Storyboard.InstantiateViewController(NavigationViewController.STORYBOARD_ID); MainViewController.ContainerController = this; SetupContainerController(MainContainerView, MainViewController); MenuViewController = (MenuViewController)Storyboard.InstantiateViewController(MenuViewController.STORYBOARD_ID); MenuViewController.ContainerController = this; SetupContainerController(MenuContainerView, MenuViewController); MenuContainerView.TranslatesAutoresizingMaskIntoConstraints = false; MenuContainerView.ClipsToBounds = true; ShowMenu(false, false); UISwipeGestureRecognizer rightSwipeGesture = new UISwipeGestureRecognizer(() => { ShowMenu(); }); rightSwipeGesture.Direction = UISwipeGestureRecognizerDirection.Right; MainContainerView.AddGestureRecognizer(rightSwipeGesture); UISwipeGestureRecognizer leftSwipeGesture = new UISwipeGestureRecognizer(() => { HideMenu(); }); leftSwipeGesture.Direction = UISwipeGestureRecognizerDirection.Left; MenuContainerView.AddGestureRecognizer(leftSwipeGesture); }
private void ShowMenu(bool show, bool animated) { float screenWidth = (float)UIScreen.MainScreen.Bounds.Width; MenuContainerView.SetNeedsUpdateConstraints(); double animationDuration; if (animated) { animationDuration = MENU_ANIMATION_DURATION; } else { animationDuration = 0; } UIView.Animate(animationDuration, () => { if (show) { MenuRightMargin.Constant = (float)(screenWidth * (1.0 - MENU_WIDTH_PERCENT)); MenuLeftMargin.Constant = 0; } else { MenuRightMargin.Constant = screenWidth; MenuLeftMargin.Constant = (float)(-screenWidth * MENU_WIDTH_PERCENT); } View.LayoutIfNeeded(); }); MainContainerView.UserInteractionEnabled = !show; IsMenuShown = show; }
void ReleaseDesignerOutlets() { if (MainContainerView != null) { MainContainerView.Dispose(); MainContainerView = null; } if (MenuContainerView != null) { MenuContainerView.Dispose(); MenuContainerView = null; } if (MenuLeftMargin != null) { MenuLeftMargin.Dispose(); MenuLeftMargin = null; } if (MenuRightMargin != null) { MenuRightMargin.Dispose(); MenuRightMargin = null; } }