how to dynamically recolor a CGGradientRef
- by saintmac
I have three CGGradientRef's that I need to be able to dynamically recolor. When I Initialise the CGGradientRef's the first time I get the expected result, but every time I attempt to change the colors nothing happens. Why?
gradient is an instance variable ins a subclass of CALayer:
@interface GradientLayer : CALayer 
{
    CGGradientRef gradient;
    //other stuff   
}
@end
Code: 
    if (gradient != NULL)
    {
        CGGradientRelease(gradient);
        gradient = NULL;
    }
    RGBA color[360];
    //set up array
    CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
    gradient = CGGradientCreateWithColorComponents
    (
    rgb, 
    color,
    NULL,
    sizeof (color) / sizeof (color[0])
    );
    CGColorSpaceRelease(rgb);
    [self setNeedsDisplay];