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
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
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:
to this:
class SideMenuViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.revealViewController().rearViewRevealWidth = self.view.frame.width - 64
}
}
It works for me!
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With