当我显示一个弹出窗口时,我试图创建一个模糊的背景,我几乎让它工作了。
我找到了一些我翻译成 C# 的 Objective C。
问题出在这一行
UIImage finalImage = new UIImage(resultImage);
希望这只是我做错了什么
private UIView CreateBlurView(UIView view)
{
UIGraphics.BeginImageContext(view.Bounds.Size);
view.Layer.RenderInContext(UIGraphics.GetCurrentContext());
UIImage viewImage = UIGraphics.GetImageFromCurrentImageContext();
// Blur Image
CIImage imageToBlur = CIImage.FromCGImage(viewImage.CGImage);
CIFilter gaussianBlurFilter = CIFilter.FromName("CIGaussianBlur");
gaussianBlurFilter.SetValueForKey(imageToBlur,new NSString("inputImage"));
gaussianBlurFilter.SetValueForKey(new NSNumber(10.0f),new NSString("inputRadius"));
CIImage resultImage = (CIImage) gaussianBlurFilter.ValueForKey(new NSString("outputImage"));
UIImage finalImage = new UIImage(resultImage);
UIImageView imageView = new UIImageView(view.Bounds);
imageView.Image = finalImage;
return imageView;
}