I am trying to change a UIImage saturation during an animation. But it seems that it is too heavy/slow to do so this way:
-(void) changeSaturation:(CGFloat)value{
CIContext * context = [CIContext contextWithOptions:nil];
CIFilter *colorControlsFilter = [CIFilter filterWithName:@"CIColorControls"];
CIImage *image = self.imageView.image.CIImage;
[colorControlsFilter setValue:image forKey:@"inputImage"];
[colorControlsFilter setValue:[NSNumber numberWithFloat:value] forKey:@"inputSaturation"];
CIImage *outputImage = [colorControlsFilter outputImage];
CGImageRef cgimg = [context createCGImage:outputImage
fromRect:[outputImage extent]];
UIImage *newImage = [UIImage imageWithCGImage:cgimg];
self.imageView.image = newImage;
CGImageRelease(cgimg);}
This method is called everytime the view is dragged by the user (when the distance changes, the saturation changes as well), which obviously is not the right way to do it but I would like a similar behavior. I wonder if I can achieve this with a layer on top of the UIImageview.
Can anyone advise me on how to achieve my goal?
Turns out my main issue was that the view being dragged contained a big resolution image. My solution above works perfectly fine.