2016-06-08 79 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。 –

相關問題