0

I'm trying to animate a blur effect up until a certain intensity. Doing so using the .animate method of UIView is trivial:

 let visualEffectView = UIVisualEffectView(effect: nil)

 UIView.animate(withDuration: 1) {
     visualEffectView.effect = UIBlurEffect(style: .regular)
 } 

, the issue here is that the final blur intensity is way too high to my needs. Does anyone know if there is another way to achieve a similar result, reducing the final blur intensity?

Some approaches i can think of:

  • animating the alpha property, but apparently Apple advices against it;
  • using UIViewPropertyAnimator and stopping the animation midway, but i've tried to search for a way to achieve this without success. The best thing i can think of is to start it and then pause it halfway its duration by using a timer, but it looks like a very bad practice to me.
oneshot
  • 591
  • 1
  • 5
  • 27
  • 1
    In my opinion? Blur has *no* thing as "intensity". Here: https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html The first category is `CICategoryBlur`. Eight filters. Most have a parameter called "Radius" - is that what you mean? Or maybe "Angle" or "Sharpness"? I'd like to help, but I'm drawing a blank on what you mean by "intensity". (And I also think `UIKit` may not be the way to go -maybe consider looking into `CoreImage`? And yes, it may be overkill.) –  Mar 03 '21 at 04:34
  • @dfd hey, thanks for your reply and i'm super sorry for the delayed answer, i totally lost this one! The point is that there's no such thing as "intensity" in UIKit, Apple didn't bother to add one. I apologize if i'm not clear as english is not my native language, to understand what i wanted to achieve think about a UIBlurEffect with its alpha property set to 0.5 instead of 1. Anyway i think i've found a way to achieve this using UIViewPropertyAnimator, its fractionComplete property and CADisplayLink, posting this as soon as it's polished. – oneshot Mar 12 '21 at 22:07

0 Answers0