Sidemenu: Dim presenting view when menu is showing

Created on 10 May 2016  路  8Comments  路  Source: jonkykong/SideMenu

When the menu is shown, I want to dim the presenting view by changing its background color. I am happy to submit a PR for this. There are two ways we could do this:

  • Add a property like menuContainerBackgroundColor property to SideMenuManager. Then it would handle the presenting view background color change as part of its animation.
  • Add a delegate to SideMenuManager. It would call a method in the delegate when it is presented or dismissed. This allows us to animate the background color changes by responding to the delegate methods and animating using menuAnimationPresentDuration or menuAnimationDismissDuration for the duration.

Any preference?

Most helpful comment

Those properties apply to the sidemenu instead of the viewcontroller that's showing the menu right? I would like to dim the view that's presenting the sidemenu, so it's clear to the user that they can't interact with the orginal viewcontroller.

All 8 comments

This is already possible with the existing properties. See menuAnimationBackgroundColor and menuAnimationFadeStrength for a very simple solution.

Those properties apply to the sidemenu instead of the viewcontroller that's showing the menu right? I would like to dim the view that's presenting the sidemenu, so it's clear to the user that they can't interact with the orginal viewcontroller.

Try them for yourself.

I did try it but I can't achieve the results I'm looking for. I did set menuAnimationBackgroundColor to UIColor.yellow and menuAnimationFadeStrength to 1.0 but only the color of the sidemenu changes and not the color of the viewcontroller that's presenting the sidemenu.

This is what's happening:
2eb33od1hp

What I'm trying to achieve:
sidemenu

@batjo SlideInOut will get you closer.

Otherwise make your changes in viewWillAppear and viewWillDisappear or use the delegate methods if that doesn't work.

Thanks I figured it out!

@batjo How did you do that. Is there an option, or did it using delegate

@batjo How did you do that. Is there an option, or did it using delegate

Try

menuNavigationController.presentationStyle = .viewSlideOutMenuIn
menuNavigationController.presentationStyle.onTopShadowColor = .black
menuNavigationController.presentationStyle.presentingEndAlpha = 0.7
Was this page helpful?
0 / 5 - 0 ratings