2016-06-08 48 views
0

我有一个在左上角有汉堡菜单的应用程序。当按下时,菜单将以90%的不透明度在当前ViewController上淡出,显示应用程序的主要导航选项。在另一个模态表示的viewController下模糊viewController?

@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) 

} 

我如何可以模糊的viewController菜单后面,当它淡入:

我从一个页面使用下面的代码呈现的viewController?

回答

0

你要模糊效果应用到您的视图这样

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) 

现在写你的代码,添加视图。

+0

因此,我将其添加到我的菜单的viewDidLoad方法中,它可以工作,但现在我的按钮都不显示。 –

+1

你的按钮在哪里? –

+0

他们在我的菜单的viewController。 –

相关问题