I have read dozens of questions about mimicking iOS 7 blur effect in earlier versions of iOS. But the fundamental question that arises here is does iOS 7's UIKit
really have a nice and convenient way to make any UIView
blurred? That seems quite logical to me. Any help appreciated.
There are two options: UIBlurEffect and UIVibrancyEffect . UIBlurEffect adds a blur over the content underneath the visual effect view and has been around since iOS 8.
Apple has provided sample code to blur any UIImage in iOS 7's style.
Go to Apple Developer downloads and log in if necessary. Search for "imageeffects" to bring up the WWDC 2013 Sample Code entry, and download the iOS_UIImageEffects sample code.
In that project, there's a UIImage category in UIImage+ImageEffects.h
that you can copy into your own project, containing the applyBlurWithRadius:...
method.
You'll need to link your project with the Accelerate framework.
This won't automatically do a blur on a view in realtime — for that, see FXBlurView, which performs a similar technique by automatically snapshotting its superview. It can be pretty performance-intensive, though: consider first whether you can achieve what you want by statically blurring an image, rather than trying to "live"-blur moving content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With