1

I was following this tutorial Customize your SWRevealViewController slide-out menu

and this is the layout of the app this how SWReveal push the main View

but the way Gmail works is to cover the main View like this photo

enter image description here

and I was wondering if could I make the silde-out menu using SWRevealViewController cover the main view like Gmail app and how to do it ?

Mohammad Eliass Alhusain
  • 1,443
  • 2
  • 12
  • 29

3 Answers3

0

Assuming only left-menu part is left and menu is sliding on button click.

Follow below steps :

  1. Take new UIViewController in your storyboard.
  2. Do this a) Add new UIView with size of UIViewController (says viewBG). b) Now goto property and decrease the viewBG opacity according to you, Don't play with alpha value. c) Take one more view of your left menu (says viewMenu).

  3. Add Your menuVC as a child VC of your MainVC.

  4. Now use below line code when you wanted to show menu.

menuVC.view.frame = CGRect(x : -self.view.frame.size.width, y : 0, width : menuVC.view.frame.size.width, height: self.view.frame.size.height) UIView.animate(withDuration: 0.5) { menuVC.view.frame = CGRect(x : 0, y : 0, width : menuVC.view.frame.size.width, height: self.view.frame.size.height) }

  1. To remove menu

menuVC.view.frame = CGRect(x : 0, y : 0, width : menuVC.view.frame.size.width, height: self.view.frame.size.height) UIView.animate(withDuration: 0.5) { menuVC.view.frame = CGRect(x : -self.view.frame.size.width, y : 0, width : menuVC.view.frame.size.width, height: self.view.frame.size.height) }

HOPE: you can give constraints to you view.

dahiya_boy
  • 7,885
  • 1
  • 25
  • 39
0

A proper answer to my question was opening this issue : How to make SWRevealViewController works like covering the main view not as default pushing the main view ? #669

Mohammad Eliass Alhusain
  • 1,443
  • 2
  • 12
  • 29
0

The way is to set your "main" view controller as the rearViewController (static, not moving) and your "side Bar" as the frontViewController (sliding on top, optionally transparent). From my understanding of what you want to achieve this is all you need.

Renya Karasuma
  • 135
  • 1
  • 10