I wonder if is possible to animate the fill color of a path I have drawn using CoreGraphics? I am drawing this: Simple drawing with Quartz - Core Graphics
and I want to change its fill color from white to let's say gray. Is this possible?
I know the existence of view.layer.content property but Is this useful here? Though, I am not sure how can I use it in this case.
Thanks in advance.
Update
I am trying this approach (its buggy, hence I can tell if its going to work) basically I am creating a CGImageRef and pass it to self.layer.contents which is animatable using UIView animations but .... I am getting strange results, besides is not animating.
int bitsPerComponent = 8;
int channels = 4;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
void *data = malloc(self.bounds.size.width*self.bounds.size.height*channels);
CGContextRef context = CGBitmapContextCreate(data, //pointer to data
self.bounds.size.width, //width
self.bounds.size.height, //height
bitsPerComponent, //bitsPerComponent
self.bounds.size.width*channels,//bytesPerRow
colorSpace, //colorSpace
kCGImageAlphaPremultipliedFirst); //bitmapInfo
//method that uses below link's code
[self _drawBackgroundInContext:context color:UIColorFromMandalaBoxType(type)];
CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, //info, NULL
data, //pointer to data
self.bounds.size.width*self.bounds.size.height*channels, //number of bytes
NULL); //release callback
CGImageRef image = CGImageCreate(self.bounds.size.width, //width
self.bounds.size.height, //height
bitsPerComponent, //bitsPerComponent
bitsPerComponent*channels, //bitsPerPixel
self.bounds.size.width*channels, //bytesPerRow
colorSpace, //colorSpace
kCGImageAlphaPremultipliedFirst, //bitmapInfo
dataProvider, NULL, false, kCGRenderingIntentDefault);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5f];
self.layer.contents = (id)image;
[UIView commitAnimations];
CGImageRelease(image);
CGDataProviderRelease(dataProvider);
CGContextRelease(context);
free(data);
CGColorSpaceRelease(colorSpace);
Is logic OK?, and where is the mistake here? ;(