Show BlurEffect on manual segue

56 views Asked by At

I have a question regarding blureffects on a view controller. I program all of my segues manually for several reasons. But when I go to a viewcontroller that has a blureffect background, I only see a dark gray background. How can I solve this that the view controller blur effect lays on top of another viewcontroller where the content of the previous viewcontroller can be seen through?

The blureffects are now applied by storyboard with transparant background views.

My code for seque is:

Action:

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

Class:

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
}

}

Hope you can help me with this because it will maximize aesthetics for the app :D

2

There are 2 answers

0
vandernat.p On

Alright for others to know, what worked for me was the following:

At IBAction: adding the following line before presenting

controller.modalPresentationStyle = UIModalPresentationStyle.overFullScreen

Like this:

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

try this.

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