我想知道是否可以在滑动滑块时更新 aUIImage
以UIImageView
增加用于在图像中产生模糊效果的浮点值?到目前为止,我的滑块设置了一个浮点值,一个按钮根据浮点值产生模糊效果。任何代码都会很棒。
它看起来像这样:
float hello = [slider value];
CIFilter *gaussianBlurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[gaussianBlurFilter setDefaults];
[gaussianBlurFilter setValue:[CIImage imageWithCGImage:[imageView.image CGImage]] forKey:kCIInputImageKey];
[gaussianBlurFilter setValue:@(hello) forKey:kCIInputRadiusKey];
CIImage *outputImage = [gaussianBlurFilter outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGRect rect = [outputImage extent];
// these three lines ensure that the final image is the same size
rect.origin.x += (rect.size.width - imageView.image.size.width ) / 2;
rect.origin.y += (rect.size.height - imageView.image.size.height) / 2;
rect.size = imageView.image.size;
CGImageRef cgimg = [context createCGImage:outputImage fromRect:rect];
UIImage *image = [UIImage imageWithCGImage:cgimg];
CGImageRelease(cgimg);
imageView.image =image;
任何代码将不胜感激:D