I have drawn an enclosed shape using CGContext and filled a default color. I want to change the fill color on some event, how can I do that. There is only one enclosed shape in the context.
A:
I tried a lot to do so but could not, How ever i accomplished the task by recalling drawRect through [self setNeedsDisplay]. setNeedsDisplay is method of UIVIew which calls the drawRect
Ali Awais
2009-10-26 07:10:34
+1
A:
You can change the fill color by redrawing the whole shape. As you mention, just call [self setNeedsDisplay]
and in your drawRect:
implementation change the fill color according to the event.
Unfortuntely, you can't change the shape fill color without redrawing, but depending on the case, you can avoid redrawing and achieve the effect you require by other means like changing the blending mode. Look into the CGContext documentation to see if there is something that can suits your needs.
Dimitris
2010-01-16 10:25:39