b2cloud

19th September 2013

Live blurring views in iOS7

Guides | Tutorial By 3 years ago

One of the new effects in iOS7 is blurred content. At WWDC this year they were showing off how to do this with snapshots and image filtering. The downside to that is that it’s a static image and wont change with the content behind the view.

There’s a pretty easy way to do this live. The toolbars in iOS7 will blur what’s behind them, so you can just create a toolbar as large as you need and place it over the content you need blurred.

UIView* view = self.view;
UIToolbar* blurredView = [[UIToolbar alloc] initWithFrame:view.bounds];
[blurredView setBarStyle:UIBarStyleBlack];
[view addSubview:blurredView];

UIView* view = self.view;
UIToolbar* blurredView = [[UIToolbar alloc] initWithFrame:view.bounds];
[blurredView setBarStyle:UIBarStyleDefault];
[view addSubview:blurredView];

 

You can also adjust the alpha on the toolbar to get a more subtle blur. The bar tint colour can be used too.

UIView* view = self.view;
UIToolbar* blurredView = [[UIToolbar alloc] initWithFrame:view.bounds];
[blurredView setBarStyle:UIBarStyleBlack];
[blurredView setBarTintColor:[UIColor redColor]];
[view addSubview:blurredView];

  • Joe Barbour

    This is great stuff, is there anyway of adding a fade animation to this method?

    • Tom

      You can animate the alpha of the UIToolbar between 0 and 1 to get it to fade in nicely

  • Alejandro Luengo Gomez

    thanks for that 🙂

  • Phong Le

    The last one doesn’t work .

    • Tom

      Hmm they must have changed some stuff since iOS 7.0.0

      You can get it a red-ish blur by changing the alpha on the redColor, however it doesn’t look nearly as good

      • Phong Le

        Yea, I tried that the results don’t look that spectacular.

Recommended Posts

CGContext drawing in a thread

Post by 3 years ago

The CGContext provides a great way to draw to the screen on iOS, I use it often to draw custom images. Something that didn't occur to me initially when I used the UIGraphicsGetCurrentContext() method to...

Got an idea?

We help entrepreneurs, organizations and established brands from around
the country bring ideas to life. We would love to hear from you!