void RemoveMenuBlurForMenu(UISideMenuNavigationController forMenu) { if (forMenu == null) { return; } var originalMenuBackgroundColor = forMenu.OriginalMenuBackgroundColor; var view = forMenu.VisibleViewController?.View; if (forMenu == null || originalMenuBackgroundColor == null || view == null) { return; } view.BackgroundColor = originalMenuBackgroundColor; forMenu.OriginalMenuBackgroundColor = null; var tableViewController = forMenu.VisibleViewController as UITableViewController; var blurView = view.Subviews != null && view.Subviews.Length > 0 ? view.Subviews[0] as UIVisualEffectView : null; if (tableViewController != null) { tableViewController.TableView.BackgroundView = null; tableViewController.TableView.SeparatorEffect = null; tableViewController.TableView.ReloadData(); } else if (blurView != null) { blurView.RemoveFromSuperview(); } }
void SetupMenuBlurForMenu(UISideMenuNavigationController forMenu) { RemoveMenuBlurForMenu(forMenu); var view = forMenu.VisibleViewController?.View; if (forMenu == null || view == null || UIKit.UIAccessibility.IsReduceTransparencyEnabled) { return; } if (forMenu.OriginalMenuBackgroundColor == null) { forMenu.OriginalMenuBackgroundColor = view.BackgroundColor; } if (!BlurEffectStyle.HasValue) { return; } var blurEffect = UIBlurEffect.FromStyle(BlurEffectStyle.Value); var blurView = new UIVisualEffectView(blurEffect); view.BackgroundColor = UIColor.Clear; var tableViewController = forMenu.VisibleViewController as UITableViewController; if (tableViewController != null) { tableViewController.TableView.BackgroundView = blurView; tableViewController.TableView.SeparatorEffect = UIVibrancyEffect.FromBlurEffect(blurEffect); tableViewController.TableView.ReloadData(); } else { blurView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth; blurView.Frame = view.Bounds; view.InsertSubview(blurView, atIndex: 0); } }
void SetupNavigationController(UISideMenuNavigationController forMenu, bool leftSide) { if (forMenu == null) { return; } var exitPanGesture = new UIPanGestureRecognizer(); exitPanGesture.AddTarget(/*SideMenuTransition.self, */ () => SideMenuTransition.HandleHideMenuPan(exitPanGesture)); forMenu.View.AddGestureRecognizer(exitPanGesture); forMenu.TransitioningDelegate = SideMenuTransition.TransitioningDelegate; forMenu.ModalPresentationStyle = UIModalPresentationStyle.OverFullScreen; forMenu.LeftSide = leftSide; if (leftSide) { LeftSwipeToDismissGesture = exitPanGesture; } else { RightSwipeToDismissGesture = exitPanGesture; } UpdateMenuBlurIfNecessary(); }