IPhone transparent CGContext

I create a circle with a beautiful shadow with this code (I use MonoTouch.net for iPhone, Objective-C answers, of course, of course)

        UIGraphics.PushContext (ctx);
        SizeF shadowSize = new SizeF (0f, -3f);
        ctx.SetRGBFillColor (194f / 255f, 212f / 255f, 238f / 255f, 1f);
        ctx.SetAllowsAntialiasing (true);
        ctx.SetShadowWithColor (shadowSize, 20, new CGColor (0.9f, 0.7f));
        RectangleF area = new RectangleF (35f, 15f, 210f, 210f);
        ctx.FillEllipseInRect (area);
        UIGraphics.PopContext ();

Then I want to add an arc and lines to it. When I do this, colors and shadow, etc., seem to remain? How do I start fresh when drawing my UIView? (All this in the same UIView, I create an image)

+5
source share
2 answers

If you want to clear everything that was painted so that you have an empty canvas, try CGContextClearRectbefore you draw something.

, , , , .. , , . , . , CGContextSetShadowWithColor . NULL , .

. CGContextSetShadow, . .

, , Apple. , MonoTouch.net API Objective-C .NET . , Google iPhone OS.

+13

, :

CGContextSaveGState(ctx);

, , , , :

CGContextRestoreGState(ctx);
+1

All Articles