簡體   English   中英

在另一個模態呈現的viewController下模糊viewController?

[英]Blurring viewController underneath another modally presented viewController?

我在左上角有一個帶有漢堡菜單的應用程序。 按下時,菜單以90%的不透明度淡入當前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?

您必須像這樣將模糊效果應用於視圖

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)

現在,編寫添加視圖的代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM