views:

418

answers:

1

Hello! I've a custom shape drawing using coregraphics and i want to add a drop shadow and a gradient to it also. I've been trying and searching a lot of informations on how to combine and do this, but i can't get it to work. I'm able to draw only one either. Anyone doing this already or know how to do this? Thank you.

+1  A: 

Quartz only applies shadows to fills and strokes. Drawing a gradient does not count as a fill.

Fill with a solid color (to draw the shadow), then draw the gradient in the same area.

Peter Hosey
so just to clarify...1. draw a shape with solid color fill2. save the state3. draw the shadow4. restore the state5. draw the same shape as point 1 but with the gradientis this correct? so i need to draw the shape 3 times right?
Luke
There is no way to “draw the shadow”. Quartz draws the shadow for you when you fill or stroke. So, set the shadow, then fill (with a solid color) the shape, then draw the gradient over it.
Peter Hosey
thank you very much. now i understand...and it works :)
Luke
Looks like you're right Peter, but I think it might be an oversight, albeit a difficult one to fix. Images and text draw shadows, for example, as do transparency layers and CGLayers. I cannot think of any non-shading based drawing that _doesn't_ produce a shadow. The header just says "After a shadow is specified, all objects drawn subsequently will be shadowed."
Ken