4

I am trying to darken the front view when I reveal the rear view. is there any way to do this?

swift please (I'm not very experienced with objc.. I know, I know- no need to preach..)

Thanks

Shlomo Koppel
  • 885
  • 7
  • 14

1 Answers1

9

In your MenuVC (the table View controller that lies behind and acts as a side menu). Add the following.

let darkView = UIView()

override func viewWillAppear(_ animated: Bool) {

    darkView.addGestureRecognizer(revealViewController().tapGestureRecognizer())
    darkView.backgroundColor = UIColor.black.withAlphaComponent(0.7)
    darkView.frame = self.revealViewController().frontViewController.view.bounds
    self.revealViewController().frontViewController.view.addSubview(darkView)
}

override func viewWillDisappear(_ animated: Bool) {
    darkView.removeFromSuperview()
}
Munib
  • 957
  • 1
  • 14
  • 30