8

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

Vasily
  • 3,740
  • 3
  • 27
  • 61
  • i know how to add, i need to change effect without recreating view – Vasily Apr 23 '15 at 14:27
  • The `UIVisualEffectView` properties `effect` and `contentView` are read-only, but you might be able to re-use the `contentView`. – A-Live Apr 23 '15 at 14:31

1 Answers1

14

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)

Fansad PP
  • 459
  • 4
  • 11
  • Thank you Fansad for the proper solution.. guys please upvote for this solution. –  Nov 02 '18 at 09:50