I have been searching for an answer to this question in a few hours now, and I just can't figure it out. I want to add a gaussian blur effect to the image when i press the button "Button". The user is the one that is adding the image.
I have created an action for the "Button" based on sources from SO and other places on the web. It will not work. What am I doing wrong? Any code would …
我在尝试模糊iOS应用中的部分屏幕时遇到了麻烦.请参阅图片以更好地了解我正在尝试做什么.

只有"BlurBox"的内容需要模糊,但其余内容可以清晰.因此,如果您正在查看表格视图,则只有BlurBox下方的内容会模糊(即使您滚动).其余的看起来很清楚.
我的第一个方法是调用UIGraphicsGetImageFromCurrentImageContext()每个.01s来将BlurBox下的所有图层组合成一个图像.然后模糊该图像并将其显示在所有内容上.
我尝试模糊的方法是:
https://github.com/tomsoft1/StackBluriOS
https://github.com/coryleach/UIImageAdjust
https://github.com/esilverberg/ios-image-filters
https://github.com/cmkilger/CKImageAdditions
[layer setRasterizationScale:0.25];
[layer setShouldRasterize:YES];
Run Code Online (Sandbox Code Playgroud)
以及一些自定义尝试.我也看过Apple的GLImageProcessing,但我认为对于我在这里尝试做的事情来说有点矫枉过正.
问题是,他们都是以 减缓.该应用程序不在应用程序商店上,所以我愿意使用任何私有/未记录的框架.
我有一种很远的想法是覆盖drawRect我使用的所有组件(UITableViewCells,UITableView等)的方法,并在运行中独立模糊它们.然而,这需要一些时间,这听起来像是一个可行的选择吗?
更新:
我尝试使用CIFilters如下:
CIImage *inputImage = [[CIImage alloc] initWithImage:[self screenshot]];
CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[blurFilter setDefaults];
[blurFilter setValue: inputImage forKey: @"inputImage"];
[blurFilter setValue: [NSNumber numberWithFloat:10.0f]
forKey:@"inputRadius"];
CIImage *outputImage = [blurFilter valueForKey: @"outputImage"];
CIContext *context = [CIContext contextWithOptions:nil];
self.bluredImageView.image = [UIImage imageWithCGImage:[context createCGImage:outputImage fromRect:outputImage.extent]];
Run Code Online (Sandbox Code Playgroud)
这确实有效,但速度非常慢.:(
我发现只有当我传入从磁盘加载的图像时,某些实现才会模糊.如果我传入我使用UIGraphicsGetImageFromCurrentImageContext()它创建的UIImage 不起作用.关于为什么会这样的任何想法?
更新:
我试过如下的Patel建议:
CALayer *backgroundLayer …Run Code Online (Sandbox Code Playgroud) image core-graphics image-processing objective-c uiimageview