[ad_1]
I’m attempting to use blur impact when presenting a view modally utilizing a customized UIPresentationController. The view behind is darkened out however not blurred in any respect. I require to make use of a customized modalPresentationStyle, however I can not get this to work. I’ve seen different questions on this, however it’s only about utilizing a .OverCurrentContext model. This makes me imagine it isn’t attainable to attain the blur impact utilizing a customized presentationController.
Modal Presentation Controller
class ModalPresentationController: UIPresentationController {
let blurEffectView: UIVisualEffectView!
init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?) {
let blurEffect = UIBlurEffect(model: UIBlurEffect.Type.darkish)
blurEffectView = UIVisualEffectView(impact: blurEffect)
tremendous.init(presentedViewController: presentedViewController, presenting: presentingViewController)
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.blurEffectView.isUserInteractionEnabled = true
self.blurEffectView.addGestureRecognizer(tapGestureRecognizer)
}
override func presentationTransitionWillBegin() {
self.blurEffectView.alpha = 0
self.containerView?.addSubview(blurEffectView)
self.presentedViewController.transitionCoordinator?.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) in
self.blurEffectView.alpha = 0.8
}, completion: { (UIViewControllerTransitionCoordinatorContext) in
})
}
Presentating View
internet hosting.view.backgroundColor = .clear
internet hosting.modalPresentationStyle = .customized
internet hosting.transitioningDelegate = self
[ad_2]