Interactive blurring of UIImage and UIView as iOS 8 spotlight

iOS 8 is a pretty fun interactive blur. In particular, there is interactive blur when you step out onto the spotlight, but there is also animation when Siri opens and closes (although it is not interactive). I only noticed this interactive blur elsewhere: the official Twitter app when changing profile view (the parallax header image often changes and blurs).

I tried animating something basic with a UISlider with both CoreImage and GPUImage (based on the answer to this question and also Apple's UIImage + ImageEffects , but nothing seems to be good enough to animate the blur interactively (i.e. blur images by one value runs fast once, but not at frame rate fast enough to blur).

How can I implement these methods in such a way that they are efficient enough to both blur and blur UIImage (and ideally a UIView snapshot or CIContext)?

+3


source to share


1 answer


There is no simple and unique way to do this, but it is definitively doable if you follow these steps and additional methods:

  • Most importantly: scale down the image. The underlying resolution is not very important for Gaussian blur. If you only reduce to half the resolution, the amount of data is reduced to a quarter!

  • Determine the blur radius of the final target.

  • Extract the device architecture using C functions and of course use different values ​​for the saturation delta parameter for different architectures, depending on the processing power.

  • An experiment creating blur with Apple provided a library with a radius step relative to the step value of the parameter that interacts with (for example, using the KVO to property contentOffset

    ). dispatch_async and don't forget the blurry image callback to the main queue!

  • The methods above will almost certainly satisfy all architectures from arm7s, but you may have problems with arm7 - iPhone 4s.

  • If you still have problems, for example with the specified arm7, then double the change contentOffset

    needed for the next blur with the next radius. Then, rather than changing the image property in the UIImageView, rather create a new UIImageView with the new blurry UIImage and fade in alpha from 0 to 1 during the period that the next blurry page is generated.

  • You can use a number of tricks, for example, create all blurry images one by one for full interactive scale and cache them in a collection and use them in the method described in point 6.



There are also many other techniques out there if the animation is not interactive but rather synchronized at a specific frame.

0


source







All Articles