在手动segue上显示BlurEffect

时间:2017-09-18 09:18:25

标签: ios segue viewcontroller uiblureffect

我对视图控制器上的blureffects有疑问。我手动编程所有segue有几个原因。但是当我去一个具有blureffect背景的viewcontroller时,我只看到一个深灰色的背景。如何解决这个问题,视图控制器模糊效果位于另一个可以看到前一个viewcontroller内容的viewcontroller之上?

blureffects现在由具有透明背景视图的故事板应用。

我的seque代码是:

动作:

@IBAction func ToUserSections(_ sender: Any) {
        let controller = 
        Navigation.getDestinationViewControllerWith("User", 
        controllerName: "UserSectionsVC")
        present(controller, animated: false, completion: nil)
    }

类别:

class Navigation{
    static func getDestinationViewControllerWith(_ 
    storyboardName:String, controllerName:String)-> UIViewController{

    let storyboard = UIStoryboard(name: storyboardName, bundle: nil)
    let controller = 
    storyboard.instantiateViewController(withIdentifier: 
    controllerName) as UIViewController

    return controller
}

}

希望你能帮助我,因为它会最大化应用程序的美感:D

2 个答案:

答案 0 :(得分:0)

试试这个。

 let viewController : CustomViewControlller = UIStoryboard.getMainStoryboard().instantiateViewController(withIdentifier: "Identifier") as! CustomViewControlller        
  viewController.modalPresentationStyle = .overCurrentContext
  viewController.modalTransitionStyle = .crossDissolve
  self.present(viewController, animated: true, completion: { _ in })

答案 1 :(得分:0)

其他人知道,对我有用的是:

在IBAction:在呈现

之前添加以下行
controller.modalPresentationStyle = UIModalPresentationStyle.overFullScreen

像这样:

@IBAction func ToUserSections(_ sender: Any) {
    let controller = Navigation.getDestinationViewControllerWith("User", controllerName: "UserSectionsVC")
    controller.modalPresentationStyle = UIModalPresentationStyle.overFullScreen
    present(controller, animated: false, completion: nil)
}