0

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

vandernat.p
  • 153
  • 1
  • 1
  • 10

2 Answers2

0

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 })
  • Thank you for the reply. Could you elaborate on your answer. Where do I need to place this and what do I need to leave out? Thank you – vandernat.p Sep 18 '17 at 13:12
  • It says now: Use of undeclared type "CustomViewController". – vandernat.p Sep 18 '17 at 13:22
  • You are suppose to replace `CustomViewControlller` with your controller name and if you are not using custom controller then just keep it UIViewController only. Main concept is using `viewController.modalPresentationStyle = .overCurrentContext viewController.modalTransitionStyle = .crossDissolve` proparties on your viewcontroller object – Aura Abhishek Sep 19 '17 at 07:08
0

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)
}
vandernat.p
  • 153
  • 1
  • 1
  • 10