Try and add this to your viewWillAppear method in your rearVieController class
revealViewController.frontViewController.view.backgroundColor = UIColor.blue //Set colour to what ever you want
So it should look like this
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
revealViewController.frontViewController.view.backgroundColor = UIColor.blue
}
Edit:
Okay I have tried to do this and it seems to work
If you create a new UIView and add it to the frontViewController then remove it when the view disappears.
var view: UIView?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//Create the view the same size as your frontViewController
view = UIView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(revealViewController.view.frame.size.width), height: CGFloat(revealViewController.view.frame.size.height)))
//Set the colour of the view to whatever you like
view?.backgroundColor = UIColor.blue
//Add the new view to the frontViewcontroller
revealViewController.frontViewController.view.addSubview(view!)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//Remove the view from the frontViewController
view?.removeFromSuperview()
}
Edit:
If you add a tap gesture to the UIView then remove the view in the tap function instead of the viewWillDisappear
var view: UIView?
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
//Create the view the same size as your frontViewController
view = UIView(frame: CGRect(x: CGFloat(0), y: CGFloat(0), width: CGFloat(revealViewController.view.frame.size.width), height: CGFloat(revealViewController.view.frame.size.height)))
//Set the colour of the view to whatever you like
view?.backgroundColor = UIColor.blue
//Add a tap gesture to the UIview
let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap(_:)))
view?.addGestureRecognizer(tap)
//Add the new view to the frontViewcontroller
revealViewController.frontViewController.view.addSubview(view!)
}
func handleTap(_ sender: UITapGestureRecognizer) {
//Remove the view from the frontViewController
view?.removeFromSuperview()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
//Moved the remove to the tap gesture function
}