How to Produce an Effect Similar to the iOS 7 Blur View

iOS 7 style Blur view

You might be able to modify something like Bin Zhang's RWBlurPopover to do this. That component uses my GPUImage to apply a Gaussian blur to components underneath it, but you could just as easily use a CIGaussianBlur for the same. GPUImage might be a hair faster though.

That component relies on you being able to capture the view behind the one you're presenting, though, and may have trouble with views that animate behind this content. The need to take a trip through Core Graphics to rasterize the background view will slow things down, so we probably don't have sufficiently direct access to be able to do this in a performant manner for overlays on animating views.

As an update to the above, I recently reworked the blurs in GPUImage to support variable radii, allowing for the complete replication of the blur size in iOS 7's control center view. From that, I created the GPUImageiOS7BlurFilter class that encapsulates the proper blur size and color correction that Apple appears to be using here. This is how GPUImage's blur (on the right) compares to the built-in blur (on the left):

Apple's blur GPUImage's blur

I use a 4X downsampling / upsampling to reduce the number of pixels the Gaussian blur has to operate over, so an iPhone 4S can blur the entire screen in roughly 30 ms using this operation.

You still have the challenge of how to pull content into this blur from views behind this one in a performant manner.

How to make this kind of effect in iOS, blur effect it is increasing leaner to lower side

Use CAGradientLayer

UIColor *theColor = [[UIColor alloc] initWithRed:146.0/255.0 green:146.0/255.0 blue:146.0/255.0 alpha:1];

CAGradientLayer *gradientLayer = [CAGradientLayer layer];

CGRect gradientLayerFrame = theView.frame;
gradientLayerFrame.origin.x = 0;
gradientLayerFrame.origin.y = 0;
gradientLayer.frame = gradientLayerFrame;

//build the colors array for the gradient
NSArray *colors = [NSArray arrayWithObjects:
(id)[theColor CGColor],
(id)[[theColor colorWithAlphaComponent:0.9f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.6f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.4f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.3f] CGColor],
(id)[[theColor colorWithAlphaComponent:0.1f] CGColor],
(id)[[UIColor clearColor] CGColor],

gradientLayer.colors = colors;

[yourView.layer insertSublayer:gradientLayer atIndex:0];

swift version of this code is here

iOS, native blur view effects available from iOS9+?

UIKIt has a UIVisualEffectView to add the beautiful blur effects

  • from the object library drag a UIVisualEffectView and drop it on the view that needs make it blur for your case (background)

declare these properties

@IBOutlet var popupView: UIView!
@IBOutlet weak var visualEffectView: UIVisualEffectView!
var blurEffect:UIVisualEffect!

in viewDidLoad put this code

    blurEffect = visualEffectView.effect
visualEffectView.effect = nil

show a view/popup (a dialog) with blur

func presentPopUp() {
UIView.animate(withDuration: 0.4) {
self.visualEffectView.effect = self.blurEffect
//make tarnsform from popupView make it show more beauty

hide a view/popup (a dialog) and blur

func dismissPopUp () {
UIView.animate(withDuration: 0.3, animations: {
self.visualEffectView.effect = nil
//make tarnsform from popupView make it hide more beauty
}) { (success:Bool) in
// dismissPopUp remove it from super View

iOS Blur effect for a view behind when showing a UIView on top (dialog)

You can do this through many ways depending the iOS you are supporting. Here are two ways backwards compatible with before iOS8:

  • FXBlurView

  • iOS-Blur (Similar to you implement a UIToolbar view)

In iOS8 you can use a UIVisualEffectView. The process is simple and you can checkout this tutorial of Ray Wenderlich on how to do it.

Since you have asked a "programatically" way, here is a example using iOS-Blur library mentioned before:

JCRBlurView *blurView = [JCRBlurView new];
[blurView setFrame:CGRectMake(0.0f,0.0f,100.0f,100.0f)];
[self.view addSubview:blurView];

Background blur Effect?

Here is a great article that is covering several options for this effect.

It covers 3 techniques:

  • blurring with the Core Image framework
  • blurring using Brad Larson's GPUImage framework
  • blurring using Apple's UIImage+ImageEffects category

You can even get some working code here:


UIImage + Effects for iOS 7 Blur Effect Slowing App Down - 450MB?

What's most likely happening here is that you're building up a series of UIImages from the above processing, causing your application to eventually exhaust memory and crash.

Apple's UIImage+Effects category does blurring CPU-side using a series of box blurs. It's not the fastest process in the world. In addition to that, creating a UIImage can be slow, as is setting a UIImage to a UIImageView for display. Almost all of that is done on the CPU, rather than the GPU.

Therefore, if you trigger the above method every time you update a UI element, you will be dispatching a series of blocks first to the default background queue, then asynchronously to the main queue. The latter is most likely where your memory buildup is occurring, since every block there will retain the objects within it. If your processing and UIImageView updating takes longer than the interval at which the above method is triggered, you will build up blocks in your dispatch queues and each of those blocks will have UIImages within them. This will quickly cause memory buildup and a crash.

There are two ways to approach this. First, you could use dispatch semaphores to make sure that only one block is every running on your background queues. I describe a process that I use for this here. This would prevent the memory accumulation, but might not help with your blurring speed.

For that, you could look at an alternative to the blurring category Apple provides. My open source GPUImage framework has a GPU-accelerated blur that replicates Apple's default effect. If you need the darker variant of that, I talk a bit about how to modify that for this here. Going to and from UIImages is still slow, but by piping the blur through to a GPUImageView instead of a UIImageView, you'll at least replace the latter half of the slow processing you have here. Filtering directly to a GPUImageView for display keeps all of that on the GPU.

iOS 7 dynamic blur effect like in Control Center

Here are ready solutions that I've found:

1. The most unexpected: Use UIToolBar

- (id) initWithFrame:(CGRect)frame
if ((self = [super initWithFrame:frame]))
[self setup];
return self;

- (id) initWithCoder:(NSCoder *)coder
if ((self = [super initWithCoder:coder]))
[self setup];
return self;

- (void) setup
if (iOS7OrLater)
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:self.bounds];
toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
toolbar.barTintColor = self.tintColor;
[self insertSubview:toolbar atIndex:0];

UIToolbar can be used for this needs, bacuse it has his only build-in blur mechanism, and this mechanism is dynamic, what is good. But the bad thing is that in some reason it ignores colors and makes background looks irredeemably...

Toolbar effect


To avoid color breaking, do not use barTintColor. You also may change style of toolbar if you want dark styled blur (use UIBarStyleBlack).

2. FXBlurView.

Unlike toolbar it more positive, but it's dynamic mechanism is rare yet and in fact it can be used only for static background. (dynamic = NO).

FBBlurView effect

Related Topics

Leave a reply