I was doing research recently on how to blur image in iOS. There are special libraries like simple-iphone-image-processing and UIImage-Blur but there turns to be a simple solution that works not just for UIImage but for any UIView. The idea is to rasterize view's content to bitmap and then scale it down and then up.
Now, granted, the result is not perfect but when the UIView goes in background and you want to emphasize that it is inactive this approach is fine. So I've created a simple project where blurView contains UIImageView and UILabel. 'Toggle Blur' button toggles the effect:


The implementation is very short, here it is:
- (IBAction)toggleBlur {
CALayer *layer = [self.blurView layer];
blur = !blur;
if (blur) {
[layer setRasterizationScale:0.3];
[layer setShouldRasterize:YES];
} else {
[layer setRasterizationScale:1.0];
[layer setShouldRasterize:NO];
}
}
If you have any ideas how to make it better or use some similar technique—let me know!






