dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *ciImage = [CIImage imageWithCGImage:image.CGImage];
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
[filter setValue:ciImage forKey:kCIInputImageKey];
/// 模糊程度
[filter setValue:@15.0f forKey: @"inputRadius"];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef outImage = [context createCGImage: result fromRect:ciImage.extent];
UIImage *blurImage = [UIImage imageWithCGImage:outImage];
dispatch_async(dispatch_get_main_queue(), ^{
self.iconBGView.image = blurImage;
});
});
网友评论