dekatotoro / SlideMenuControllerSwift

iOS Slide Menu View based on Google+, iQON, Feedly, Ameba iOS app. It is written in pure swift.
MIT License
3.4k stars 754 forks source link

Translucent / blurred menu view possible? #187

Open timlehr opened 8 years ago

timlehr commented 8 years ago

Hey guys,

I'm currently playing around with the project and loving what I'm getting so far. One question though: Is there currently a way to make the (left) menu view translucent, so I get a nice frosted glass effect over what's displayed in the content view? I tried some stuff with UIVisualEffectView but I can't get it working.

Help would be much appreciated. Thanks.

mkeefe commented 8 years ago

@timlehr

Bit late, but i'll explain how I got the blur background to work on the slide out menu. I'm sure you've completed the task, but if not... or if someone stumbles on this issue in the future.

Basically you just override viewDidLoad() in your slide out menu view controller.

Example:

class LeftMenuViewController: UIViewController {

    override func viewDidLoad() {

        super.viewDidLoad()

        // Set the background of the view controller to clear (transparent)
        self.view.backgroundColor = UIColor.clearColor()

        // Create a blur effect
        let blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
        let blurEffectView = UIVisualEffectView(effect: blurEffect)

        // Fill the view
        blurEffectView.frame = view.bounds

        // Ensure the blur conforms to resizing (not used in a fixed menu UI)
        blurEffectView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]

        // Add the view to the view controller stack
        view.addSubview(blurEffectView)

        // Ensure the blur view is in the back
        self.view.sendSubviewToBack(blurEffectView)

    }

}