Reputation: 7766
I'm trying to show a view / popup (a dialog), however I need a blur effect in the background and support iOS 9+.
Are they blur operations provided natively in UIKit which will support rotation?
I'm concerned that the blur effect will work off a screenshot and once I've shown my dialog and the screen rotates it won't be possible to add a blur effect to the screenshot image.
Perhaps there are other options.
Upvotes: 1
Views: 461
Reputation: 476
UIKIt has a UIVisualEffectView to add the beautiful blur effects
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
}
}
Upvotes: 1