Ios 7 blur effect xcode

It will look similar to the following:. Tap the Menu in the upper-left of the screen the three horizontal stripes. Beyond looking cool, blurs communicate three important concepts to the users of your apps: Depth provides cues to the user that the interface is layered, and helps them understand how to navigate your app. Previous iOS versions communicated depth with three-dimensional bevels and glossy buttons reflecting an emulated light source, but iOS 7 communicates depth using blurs and parallax. The parallax effect is evident when you tilt your iOS 7 device from side-to-side.

This provides cues to the user that the interface is composed of different layers, and that important elements sit on top of other less important interface elements — which leads into the next concept: Context allows a user to get a sense of bearing within your app. Animated transitions provide excellent context; instead of having a new view instantly appear when you tap a button, animating between the views gives the user a moment to understand where the new view originates from, and how they may get back to the previous one.

Blurs allow you to show the previous view in the background, albeit out of focus, to give the user even more context as to where they were a moment ago. The Notification Center is a great example of this; when you pull it down, you can still see the original view in the background whilst you work on another task in the foreground.

Focusing on selective items removes clutter and lets the user navigate quickly through the interface. Users will instinctively ignore elements that are blurred, focusing instead on the more important, in-focus elements in the view. You will implement two different types of blurs in this tutorial: Static Blur and Dynamic Blur. Static blurs represent a snapshot in time and do not reflect changes in the content below them. In most cases, a static blur works perfectly fine. Dynamic blurs, in contrast, update as the content behind them changes. The first step in creating a static blur is converting the current on-screen view into an image.

Apple provides some wonderful APIs to convert any view into an image — and there are some new ones in iOS 7 to do it even faster.

Create iOS 7 blur effect with latest APIs

The snapshotting APIs give you the ability to capture not just a single view, but also the entire view hierarchy. That means if you instruct it to capture a view, it will also capture all the buttons, labels, switches and various views that are placed on top of it. That way, you can quickly and easily convert any view and its contained view hierarchy into an image — and get some code reuse to boot!

These two lines are bookends for what is known as the image context. A context can be one of several things; it can be the screen, or as in this case, an image. The net effect of these two lines is an off-screen canvas on which to draw the view hierarchy. Add the following import to the top of DropDownMenuController.

Clear Facts on Blurs

Here you ensure you capture not just the view but its superview as well. To test out your code, add a breakpoint on the line directly below the call to convertViewToImage. The program will halt execution when it hits the breakpoint and you can view the captured image to make sure your code is functioning properly. To add a breakpoint, click in the margin to the left of the line and Xcode with mark the spot with a blue arrow, as shown below:.

To preview the image, select image in the lower left hand pane of the debugger, then click the Quick Look icon as indicated below:. The GPUImage framework has already been added to the project; you just need to import the header. Add the following declaration to the implementation block of DropDownMenuController. Find the breakpoint you added earlier, right click it and select Delete Breakpoint , as follows:. Now would be a great time to initialize your blur filter. Add the following code to DropDownMenuController. These statements act as the glue which bonds everything together.

Using UIImageEffects

You add the filter as a target of the picture, and then the image view as a target of the filter. The final result will simply show up in the image view when the processing is complete. The contentsScale property defines the mapping between the logical coordinate space of the layer measured in points and the physical coordinate space measured in pixels. Higher scale factors indicate that each point in the layer is represented by more than one pixel at render time.

If you reset the contentScale back to 2. Add the following line to show in DropDownMenuController. Build and run your app; tap Menu , close the menu, and then tap Menu again. What does your menu look like now? The half-size black box is no longer a problem — but now you have a full-size black box to contend with! This issue comes about the second time you calculate the blur; the proper way to solve this is to remove all of the targets from the blur which resets the filter.

This new method has a completion block that runs once the image processing is complete. Once the image is completely processed, you can safely remove all of the targets. The blurred image is sliding in from the top. You really want it to appear as if the blur effect itself is sliding down the screen. This is where you need to play some tricks with the static blur. When the menu comes down, you need to align the blur with the backdrop instead. So instead of shifting the image view down, you need to expand it, starting at size zero and expanding to full size.

This ensures the image will stay in place as the menu opens. You already have the menu open to the full size in show — you just need to set the height of contentRect to zero when the image view is first created and when it is hidden. Still in the same file, add the following line to the bottom of the animation block in: The contentRect property can be animated as well; therefore the original and updated rects will be interpolated automatically during the animation.

Build and run your app. Once you've determine that you would just need to grab an image of the part of the UI so that it can be blurred. Something like this You could also use a box blur using the following boxBlurImageWithBlur: UIImage category.

This is based on an algorythem that you can find here. Now that you are calculating the screen area to blur, passing it into the blur category and receiving a UIImage back that has been blurred, now all that is left is to set that blurred image as the background of the view you will be presenting. Like I said, this will not be a perfect match for what Apple is doing, but it should still look pretty cool. I just wrote my little subclass of UIView that has ability to produce native iOS 7 blur on any custom view.

It uses UIToolbar but in a safe way for changing it's frame, bounds, color and alpha with real-time animation.

objective c - iOS 7 style Blur view - Stack Overflow

There is a rumor that Apple engineers claimed, to make this performant they are reading directly out of the gpu buffer which raises security issues which is why there is no public API to do this yet. This is a solution that you can see in the vidios of the WWDC. You have to do a Gaussian Blur, so the first thing you have to do is to add a new.

At the end the blured image will be the background and the rest of the controls above has to be transparent. You can find your solution from apple's DEMO in this page: Here is a really easy way of doing it: Okay, it's not as blurry as control center, but is's blurry enough.

Core Image

If you prefer leave all this image processing to the GPU And you should you can get a much better effect and also awesome times rounding 50ms supposing that you have a time of 1 second in the first approach , so, lets do it. Next, Add the following classes. You can try using my custom view, which has capability to blur the background. It does this by faking taking snapshot of the background and blur it, just like the one in Apple's WWDC code.

It is very simple to use. I also made some improvement over to fake the dynamic blur without losing the performance. The background of my view is a scrollView which scrolls with the view, thus provide the blur effect for the rest of the superview. See the example and code on my GitHub. Thank you for your interest in this question.

Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site the association bonus does not count. Would you like to answer one of these unanswered questions instead? How can I produce an effect similar to the iOS 7 blur view? Ask Question. I'm trying to replicate this blurred background from Apple's publicly released iOS 7 example screen: It's obvious that iOS 7 doesn't capture the contents of the views below, for many reasons: Doing some rough testing, capturing a screenshot of the views below and applying a CIGaussianBlur filter with a large enough radius to mimic iOS 7's blur style takes seconds, even on a simulator.

The iOS 7 blur view is able to blur over dynamic views, such as a video or animations, with no noticeable lag. Snowman Snowman I think we can assume that apple is using pure GL to render the home screens anyway. As I indicated in the comments to my answer here: Gaussian blurs can be made much faster than the generalized Gaussian blur cases if they have a fixed radius, or even use interesting optimizations like integral images. BradLarson - To paraphrase Jessica Simpson I have no idea what all that means but it sounds cool as heck!

But seriously, are you saying that you can use a partially transparent view with a a blur filter and lay it over another view to achieve this effect? Why bother replicating the effect? Just draw a UIToolbar behind your view. I disagree with crizzwald. I don't think that's a good interpretation of the rules of expectation of what APple will do. While he certainly would not endorse this approach, he recognized the need for the effect and the lack of real public API for this, and said that this approach was the "least evil" option for now and is fairly safe as written.

He also strongly suggested to file Radar bug reports on this, to build a case internally so we can get a real public API for this effect! Makes you wonder if this is not an unofficial post by someone who knows more than the rest of us about these things: This does not work on iPhone 4 running iOS 7. Chris Droukas 2, 17 I see the video, I can watch it, but can't figure out where to download the sample code!

I didn't see much difference compared to a simple background alpha change; perhaps it's because I'm displaying videos and they just need more blur The view that is to be blurred. Hope it helps. Jeremy Fox Jeremy Fox 2, 1 21 It seems that the blurred image's blue color and red color are swopped. It looks like someone has used your code to create this project: