支持iOS 6.0 and later
CIContext *context = [CIContext contextWithOptions:nil]; CIImage *inputImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@"1.png"]]; // create gaussian blur filter CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; [filter setValue:inputImage forKey:kCIInputImageKey]; [filter setValue:[NSNumber numberWithFloat:10.0] forKey:@"inputRadius"]; // blur image CIImage *result = [filter valueForKey:kCIOutputImageKey]; CGImageRef cgImage = [context createCGImage:result fromRect:[result extent]]; UIImage *image = [UIImage imageWithCGImage:cgImage]; CGImageRelease(cgImage); self.mainImageView.image = image;
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/3285.html