1

I am trying to make a UIView (Genres) have a blurry background. I have tried this code. But it is too blurry:

_Genres.opaque = NO;
_Genres.backgroundColor = [UIColor clearColor];
UIToolbar *fakeToolbar = [[UIToolbar alloc] initWithFrame:_Genres.bounds];
fakeToolbar.autoresizingMask = _Genres.autoresizingMask;
[_Genres insertSubview:fakeToolbar atIndex:0];

So I tried this:

_Genres.alpha = 0.9;

But this just makes it see through not less blurry.

The UIView also needs a "live blur".

These are two images. The first one is the actual toolbar (which I want it to be like) and the second one is using the code above. They have both been taken over the same background.

enter image description here

enter image description here

As you can see underneath the toolbar the blur is a lot less intense.

How can I make it more like the original toolbar?

maxisme
  • 3,974
  • 9
  • 47
  • 97
  • You can use CoreImage as solving your problem Go for this [here](http://stackoverflow.com/a/17041983/3797226) – Jasmin Jul 03 '14 at 08:43

4 Answers4

1

You want FXBlurView: https://github.com/nicklockwood/FXBlurView. If you need blur to be live set dynamic = YES.

Otherwise it just behaves as a UIView but blurs the stuff behind it

Martin
  • 1,135
  • 1
  • 8
  • 19
  • How do you set need blur to be live set dynamic = YES. I asked the same sort of question [here](https://github.com/nicklockwood/FXBlurView/issues/69) but I got no answer – maxisme Jul 02 '14 at 21:45
  • self.myBlurryView.dynamic = YES; – Martin Jul 03 '14 at 23:31
  • would you be able to help me with this problem too? http://stackoverflow.com/questions/24542076/getting-uiview-in-separate-class-for-fxblurview – maxisme Jul 05 '14 at 09:04
0

If you are targeting iOS 7 and above, I believe that this article might be of help to you: http://www.raywenderlich.com/60968/ios-7-blur-effects-gpuimage

The author uses new iOS 7 API to create blurs that will look in place in iOS 7. And the great part is that by changing one line of code, you will be able to experiment with other different types of blur.

Roboris
  • 344
  • 3
  • 16
0

Don't even try to use UIToolbar for blur on iOS 7 unless you have some super special need for the so-called 'live blur'. Other than that I recommend you Apple's own UIImage extension. Check it out here:

https://gist.github.com/ShadeApps/a9c9944b80048ae200c1

Import it in your .m file:

#import "UIImage+ImageEffects.h"

Then use on UIImage it like this:

[ourImage applyBlurWithRadius:10 tintColor:[[UIColor blackColor] colorWithAlphaComponent:0.5] saturationDeltaFactor:0.0 maskImage:nil];

With this you can achieve better and faster effects with a ton of customization for your needs.

Sergey Grischyov
  • 11,995
  • 20
  • 81
  • 120
0

Try this,

Creating a blurring overlay view

How to apply blur to a UIView?

Also in iOS 8 it will be much easier, you can simply use UIVisualEffectView

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIVisualEffectView/

Community
  • 1
  • 1
Sasi
  • 1,666
  • 2
  • 24
  • 44