Change blur effect style on-the-fly
Asked Answered
A

1

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

Archespore answered 23/4, 2015 at 14:19 Comment(2)
i know how to add, i need to change effect without recreating viewArchespore
The UIVisualEffectView properties effect and contentView are read-only, but you might be able to re-use the contentView.Corrosion
U
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)

Urbina answered 19/12, 2017 at 11:56 Comment(1)
Thank you Fansad for the proper solution.. guys please upvote for this solution.Chlodwig

© 2022 - 2024 — McMap. All rights reserved.