Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change blur effect style on-the-fly

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).

like image 960
Vasily Avatar asked Apr 23 '15 14:04

Vasily


People also ask

What type of blur does iOS use?

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.

How do you use Visual Effect view?

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.


1 Answers

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)

like image 200
Fansad PP Avatar answered Sep 19 '22 12:09

Fansad PP