3

I need a reliable, efficient method to create iOS 7 blur effect. I've implemented Apple's applyBlurWithRadius from WWDC code (UIImage+ImageEffects). It is pretty flexible actually, it allows to change tintColor also which provides to create a darker blur effect like this:

darker ios 7 blur

But it relies on the Core Graphics and it is decreasing the scrolling performance in a table view. Then I've seen BradLarson's GPUImage library and it's GPUImageiOSBlurFilter method which replicates the iOS 7 effect and it works much faster than the UIImage+ImageEffects, so it seems more usable in my case.

But the problem is, it doesn't has any parameter like tintColor. It creates whity effect like here. Also there are other filters of GPUImage but I'm not sure I can get the effect that I want.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Ömer Faruk Almalı
  • 3,792
  • 6
  • 37
  • 63
  • You can recreate this very easily by creating a toolbar, setting the style to `UIBarStyleBlack` and setting it as the table's background view. It will give you better performance and dynamic blur. Why not try this way? – Léo Natan Apr 21 '14 at 08:13
  • @LeoNatan There is a comment [here](http://stackoverflow.com/questions/17036655/ios-7-style-blur-view/17048668#17048668) that says Apple rejects apps that uses toolbar method. – Ömer Faruk Almalı Apr 21 '14 at 08:15
  • As far as I know, what Apple rejects is grabbing the backdrop layer out of the toolbar and adding that to your view. This was the case of several smart-ass open source blur views. But I don't see why using a toolbar would cause apple to reject. Our app uses it and we have not been removed. – Léo Natan Apr 21 '14 at 08:23
  • Have a look at https://github.com/nicklockwood/FXBlurView, it seems what you needed. – limon Apr 21 '14 at 08:28
  • @mustafabesnili This one uses runloop jumps which means there will always be several frames delay. – Léo Natan Apr 21 '14 at 08:32
  • 1
    @ÖmerFarukAlmalı http://stackoverflow.com/a/18142035/983912 See this answer. Even Apple admits this is the "best" solution for now. – Léo Natan Apr 21 '14 at 08:45
  • @LeoNatan I saw that comment as well, if Apple is not going to reject that method I can use that surely. I am not obsessed with any library of course. I will try to implement toolbar method and I'm going to compare in performance manner. Beside that question is going to survive to serve GPUImage request. – Ömer Faruk Almalı Apr 21 '14 at 09:01

1 Answers1

2

As I describe in the comments here, the "whitening" effect that the GPUImageiOSBlur filter provides is due to a luminance range restriction that I apply in the last step of that operation. The filter itself is a grouped filter, where the image is first desaturated and downsampled, Gaussian blurred, and then upsampled and luminance range restricted in the last step.

That last step is performed using a GPUImageLuminanceRangeFilter, which I built to replicate the exact effect that Apple seems to apply to most of their overlay blurs. They appear to use a different color effect in others, though, so to mimic that you'll want to change that last step in the filter.

I might make this something that the user can specify as a tint color later on, but for now you can create your own custom filters based on GPUImageiOSBlurFilter and GPUImageLuminanceRangeFilter, and change your implementation of GPUImageLuminanceRangeFilter to alter the final colors to be darker than what is provided normally. You'll have to experiment with the values in that fragment shader to see what produces the effect you want.

Other people have done this, to good effect, but none have fed it back in as a pull request yet.

Community
  • 1
  • 1
Brad Larson
  • 170,088
  • 45
  • 397
  • 571