I have a shape, a CALayer, which I want to add core graphics effects to. Right now, I want to keep it simple and change the fill colour of it. How can I do this?
If you just want to change the color of the whole layer you can use:
layer.backgroundColor = [[UIColor greenColor] CGColor];
if you have a more complex shape like a path to fill, you need to overwrite the layer's drawInContext:
with sth like this:
- (void)drawInContext:(CGContextRef)context
{
//...
CGContextSetFillColorWithColor(context, [[UIColor greenColor] CGColor]);
CGContextFillPath(context);
//...
}
See Quartz 2D Programming Guide for more info.
shape.fillColor = [UIColor blackColor].CGColor;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With