Is it any way to change blur effect style on-the-fly after creating view?
E.g. i've created in Storyboard blur view, but i need to change effect style from .Light to .Dark programmatically.
I can't just re-create view, because I have information in that view and dynamic constraints (constraints change with animations in some situations).
There are two options: UIBlurEffect and UIVibrancyEffect . UIBlurEffect adds a blur over the content underneath the visual effect view and has been around since iOS 8.
Apply a visual effect view to an existing view and then apply a UIBlurEffect or UIVibrancyEffect object to apply a blur or vibrancy effect to the existing view. After you add the visual effect view to the view hierarchy, add any subviews to the contentView property of the visual effect view.
yes, we can change the blur effect style on the fly... here is the code you are looking for....
MyView.effect = UIBlurEffect(style: .light)
MyView.effect = UIBlurEffect(style: .dark)
MyView.effect = UIBlurEffect(style: .extraLight)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With