Is this the quickest way to blur a view - because for my view (UICollectionView of images) it's too slow for good UX - any tips on performance improvements, better methods?
I tried altering the scale on the BeginImageContext method (third variable), with little change in performance.
(import category on UIImage from Apple)
#UIImage+ImageEffects.h
- (UIImage*)blurViewToImage:(UIView *)view type:(int)type {
//0 -dark
//1 -light
//2 -extra light
UIGraphicsBeginImageContextWithOptions(view.frame.size, true, 0.0f);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:false];
UIImage * snappy = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
switch (type) {
case 0:
return [snappy applyDarkEffect];
break;
case 1:
return [snappy applyLightEffect];
break;
case 2:
return [snappy applyExtraLightEffect];
break;
default:
break;
}
return nil;
}