UIKIt has a UIVisualEffectView to add the beautiful blur effects
- from the object library drag a UIVisualEffectView and drop it on the view that needs make it blur for your case (background)
declare these properties
@IBOutlet var popupView: UIView!
@IBOutlet weak var visualEffectView: UIVisualEffectView!
var blurEffect:UIVisualEffect!
in viewDidLoad put this code
blurEffect = visualEffectView.effect
visualEffectView.effect = nil
show a view/popup (a dialog) with blur
func presentPopUp() {
self.view.addSubview(popupView)
UIView.animate(withDuration: 0.4) {
self.visualEffectView.effect = self.blurEffect
//make tarnsform from popupView make it show more beauty
}
}
hide a view/popup (a dialog) and blur
func dismissPopUp () {
UIView.animate(withDuration: 0.3, animations: {
self.visualEffectView.effect = nil
//make tarnsform from popupView make it hide more beauty
}) { (success:Bool) in
// dismissPopUp remove it from super View
}
}