0

I have an app with a hamburger-menu in the top-left corner. When pressed, the menu fades in over the current ViewController at 90% opacity, presenting the app's main navigation options.

I am presenting the viewController from a page using the code below:

@IBAction func navToMenu(sender: AnyObject) {

    let vc = self.storyboard!.instantiateViewControllerWithIdentifier("mainMenu")
    vc.view.backgroundColor = UIColor(red: 240/255, green: 112/255, blue: 49/255, alpha: 0.9)
    vc.modalPresentationStyle = UIModalPresentationStyle.OverFullScreen
    vc.modalTransitionStyle = UIModalTransitionStyle.CrossDissolve

    self.presentViewController(vc, animated: true, completion: nil)

}

How can I blur the viewController behind the menu when the it fades in?

Joe Sloan
  • 775
  • 2
  • 9
  • 16

1 Answers1

0

You have to apply the blur effect to your View like this

let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
//always fill the view
blurEffectView.frame = self.view.bounds
blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
self.view.addSubview(blurEffectView)

Now write your code which add your view.

Dhruv Khatri
  • 803
  • 6
  • 15