Animating Blur Radius using UIVisualEffects

iOS 9 supposedly introduces a blur radius control for a blur effect. However I did not find this in the iOS 9 api. It was also mentioned in session 107. Am I missing something or will this be added in a future beta?

Replies

If anyone would like to see the mention, it's about 17 minutes in on that sesson 107 video, but there's no info on how to do it.


It's also not mentioned in session 229 or in the headers.


¯\_(ツ)_/¯

I've also been looking for this but can't find it anywhere. I can only assume it will be added in a later beta

Arbitrary blur radius animations are not supported, but animation from Blur => No Blur => Blur are, which implicitly kicks off a blur radius animation.


You do the animtion just like you would do any other, just set the effect of the UIVisualEffectView inside of an animation block; UIKit will take care of the rest.

So if you wanted to allow scrubbing between non-blurred and blurred states, like Springboard does when you drag down for search, that is still not possible?

It is possible, but its a bit advanced to do so. If you manipulate the layer.speed and layer.timeOffset you can scrub back and forth, but you need to be careful to reset everything properly when you are done (you can't just leave layer.speed = 0 and layer.timeOffset = x or you will have issues with future animations and possibly with even basic layout).

Hi Rincewind, thanks for the anwser, but what do you mean by setting the effect inside of a animation block? I don't see there is API support change UIVisualEffectView's effect after it has been created.

Thanks:)

The effect property is now readwrite. So this code works:


UIView.animateWithDuration(0.5) { effectView.effect = newBlurEffect; }

It works! Thanks!

Rincewind,


Thank you for the post about how to animate the blur radius! But what if we aren't trying to animate the effect, but instead just want a fixed blur effect of a specific radius? Is there a property I'm not seeing that allows us to set a fixed blur radius? Or would we have to animate it and just set layer.speed = 0 and layer.timeOffset = someBlurAmount until we get the desired effect?

There really isn't support for custom blur radius. Stopping time as such would likely create unwanted side effects if you did so.

I don't understand why

UIEffectSettings

is not exposed as public API;

effectWithCustomSettings:

and so on.


[effect setValue:@50 forKeyPath:@"effectSettings.blurRadius"];

should not be "private" API!

You are always welcome to Report Bugs asking for enhancements to existing API. I would recommend filing bugs for functionality that you wish to have rather than specific implementations however.