Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing the width of the rear view in SWRevealController

I have my views designed in the storyboard. When I slide out the menu, the rear view does not automatically resize to the width of the device.

How can i set the width of the view so that it matches up with the width defined by self.revealViewController().rearViewRevealWidth?

thanks

like image 398
Ant Avatar asked Aug 30 '15 09:08

Ant


4 Answers

Just set rearViewRevealOverdraw to 0 right after you set reveal width property. for an example,

self.revealViewController().rearViewRevealWidth = 300 //put the width you need   
self.revealViewController().rearViewRevealOverdraw = 0
like image 73
GMHSJ Avatar answered Oct 30 '22 12:10

GMHSJ


What I think Ant was looking for is the same I was trying to do when I stumbled upon this question: to make the rear view controller the size of the rear view width (in my case, I wanted this to happen since I had UI elements that had to be centered in the rear view). This worked for me:

override func viewDidAppear(_ animated: Bool) {
        self.view.frame.size.width = self.revealViewController().rearViewRevealWidth
    }

It went from this:

enter image description here

to this:

enter image description here

like image 21
Iris Avatar answered Oct 30 '22 14:10

Iris


class SideMenuViewController: UITableViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    self.revealViewController().rearViewRevealWidth = self.view.frame.width - 64
  }

}

It works for me!

like image 22
Bryan Lin Avatar answered Oct 30 '22 12:10

Bryan Lin


Add this code into Menu Controller

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    self.view.frame.size.width = self.revealViewController().rearViewRevealWidth
}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    self.view.frame.size.width = self.revealViewController().rearViewRevealWidth
}

It can work with any menu. Hope this help!

like image 37
lee5783 Avatar answered Oct 30 '22 14:10

lee5783