IOS 8: Using UIVisualEffectView with Blur for Modal PopOver in Compact Mode

I am trying to make a popover look like one in a 2014 WWDC session 214.

So, I started building my application using IB, which has two views related to the “Presence as Popover” segue, as such:

enter image description here The popover view contains a text view that fills its supervisor with the following restrictions: enter image description here

To support modal popover the following code:

func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle { return .OverFullScreen } func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { let navigationController = UINavigationController(rootViewController: controller.presentedViewController) controller.presentedViewController.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "done"), animated: true) return navigationController } 

This gave me the following result: enter image description here

Then I tried to add a UIVisualEffectView with a blur effect. At first, I simply added a subview to the controller view, and after checking the View Hierarchy, I realized that my effect view was actually on top of my text view, but my text view was placed correctly. So I tried the insertSubview: atIndex: method, like:

 func presentationController(controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? { let effectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) as UIVisualEffectView effectView.setTranslatesAutoresizingMaskIntoConstraints(false) controller.presentedViewController.view.insertSubview(effectView, atIndex: 0) let viewList : [String : UIView] = ["effectView" : effectView] let navigationController = UINavigationController(rootViewController: controller.presentedViewController) controller.presentedViewController.navigationItem.setRightBarButtonItem(UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Done, target: self, action: "done"), animated: true) controller.presentedViewController.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[effectView]|", options: nil, metrics: nil, views: viewList)) controller.presentedViewController.view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[effectView]|", options: nil, metrics: nil, views: viewList)) return navigationController } 

But I still can not imagine the text representation defined in IB: enter image description here

Through the view hierarchy, I see that my text view is somehow moving under the navigation bar when I insert a UIVisualEffectView at index 0.

Any thoughts on how I can programmatically set the blur effect below my text without causing it to fade / move under the navigation bar?

Greetings

+7
ios8 swift popover uivisualeffectview uipresentationcontroller
source share
1 answer

Does this feature help?

 view.insertSubview(view: effectView, belowSubview: label) 
0
source share

All Articles