public void ShowLeftMenuViewController() { if (LeftMenuViewController == null) { return; } LeftMenuViewController.BeginAppearanceTransition(true, true); LeftMenuViewController.View.Hidden = false; if (RightMenuViewController != null) { RightMenuViewController.View.Hidden = true; } View.Window.EndEditing(true); AddContentButton(); UpdateContentViewShadow(); ResetContentViewScale(); UIApplication.SharedApplication.BeginIgnoringInteractionEvents(); UIView.Animate(AnimationDuration, () => { if (ScaleContentView) { _contentViewContainer.Transform = CGAffineTransform.MakeScale(ContentViewScaleValue, ContentViewScaleValue); } else { _contentViewContainer.Transform = CGAffineTransform.MakeIdentity(); } var currentOrientation = UIApplication.SharedApplication.StatusBarOrientation; bool isPortrait = currentOrientation == UIInterfaceOrientation.Portrait || currentOrientation == UIInterfaceOrientation.PortraitUpsideDown; var centerPointX = isPortrait ? ContentViewInPortraitOffsetCenterX + View.Frame.Width : ContentViewInLandscapeOffsetCenterX + View.Frame.Width; var centerPointY = _contentViewContainer.Center.Y; _contentViewContainer.Center = new CGPoint(centerPointX, centerPointY); _menuViewContainer.Alpha = !FadeMenuView ? 0 : 1.0f; _contentViewContainer.Alpha = ContentViewFadeOutAlpha; _menuViewContainer.Transform = CGAffineTransform.MakeIdentity(); if (ScaleBackgroundImageView) { _backgroundImageView.Transform = CGAffineTransform.MakeIdentity(); } }, () => { LeftMenuViewController.EndAppearanceTransition(); if (!_visible) { DidShowMenuViewController?.Invoke(this, LeftMenuViewController); } _visible = true; LeftMenuVisible = _visible; _menuState = MenuState.LeftOpened; UIApplication.SharedApplication.EndIgnoringInteractionEvents(); AddContentViewControllerMotionEffects(); }); StatusBarNeedsAppearanceUpdate(); }
public override void ViewDidLoad() { base.ViewDidLoad(); if (ContentViewInLandscapeOffsetCenterX == 0.0f) { ContentViewInLandscapeOffsetCenterX = (float)View.Frame.Height + 30f; } if (ContentViewInPortraitOffsetCenterX == 0.0f) { ContentViewInPortraitOffsetCenterX = (float)View.Frame.Width + 30f; } View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _backgroundImageView = new UIImageView(View.Bounds) { Image = _backgroundImage, ContentMode = UIViewContentMode.ScaleAspectFill, AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight }; _contentButton = UIButton.FromType(UIButtonType.Custom); _contentButton.TouchUpInside += (sender, e) => { HideMenuViewController(); }; View.AddSubview(_backgroundImageView); View.AddSubview(_menuViewContainer); View.AddSubview(_contentViewContainer); _menuViewContainer.Frame = View.Bounds; _menuViewContainer.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; if (LeftMenuViewController != null) { AddChildViewController(LeftMenuViewController); LeftMenuViewController.View.Frame = View.Bounds; LeftMenuViewController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _menuViewContainer.AddSubview(LeftMenuViewController.View); LeftMenuViewController.DidMoveToParentViewController(this); } if (RightMenuViewController != null) { AddChildViewController(RightMenuViewController); RightMenuViewController.View.Frame = View.Bounds; RightMenuViewController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _menuViewContainer.AddSubview(RightMenuViewController.View); RightMenuViewController.DidMoveToParentViewController(this); } _contentViewContainer.Frame = View.Bounds; _contentViewContainer.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; AddChildViewController(ContentViewController); var rect = View.Bounds; if (bannerView != null) { rect.Height -= (nfloat)bannerView.Frame.Height; } ContentViewController.View.Frame = rect; _contentViewContainer.AddSubview(ContentViewController.View); ContentViewController.DidMoveToParentViewController(this); _menuViewContainer.Alpha = 0; if (ScaleBackgroundImageView) { _backgroundImageView.Transform = CGAffineTransform.MakeScale(1.7f, 1.7f); } AddMenuViewControllerMotionEffects(); if (PanGestureEnabled) { View.MultipleTouchEnabled = false; var gesture = new UIPanGestureRecognizer(PanGestureRecognized); gesture.ShouldReceiveTouch += (r, t) => { return(ShouldReceiveTouch(r, t)); }; View.AddGestureRecognizer(gesture); } }