CoreGraphics same code draw different
<p>I write a msg background in tableviewcell, but when scrolling, the view become different. seems like the "context" store some state.
The code draw a round rect with a arrow.The arrow size should be fixed,but in fact it will change sometimes then scrolling.</p>

<pre><code> - (void)drawRect:(CGRect)rect
{
    // Drawing code
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGFloat width = self.frame.size.width;
    CGFloat height = self.frame.size.height;


    CGFloat arrowHeight = 10;
    CGFloat arrowWidth = 5;
    CGFloat arrowOffset = 5; 
    CGFloat radius = 5;
    CGFloat shadowHeight = 2;
    CGFloat shadowOffset = 4;

    CGColorRef shadowColor = [UIColor colorWithRed:0.2f
                                             green:0.2f
                                              blue:0.2f
                                             alpha:0.5f].CGColor;

    CGColorRef color;
        color = [UIColor whiteColor].CGColor;

    CGContextSaveGState(context);

        CGContextMoveToPoint(context, width/2, 0);
        CGContextAddArcToPoint(context, width - arrowWidth, 0, width - arrowWidth, height - shadowOffset, radius);
        CGContextAddLineToPoint(context, width - arrowWidth, arrowOffset);
        CGContextAddLineToPoint(context, width, arrowOffset + arrowHeight/2);
        CGContextAddLineToPoint(context, width - arrowWidth, arrowOffset + arrowHeight);
        CGContextAddArcToPoint(context, width - arrowWidth, height - shadowOffset, shadowOffset, height - shadowOffset, radius);
        CGContextAddArcToPoint(context, shadowOffset, height - shadowOffset, shadowOffset, 0, radius);
        CGContextAddArcToPoint(context, shadowOffset, 0, width, 0, radius);

    CGContextSetShadowWithColor(context, CGSizeMake(0, shadowHeight), 3.0, shadowColor);
    CGContextSetFillColorWithColor(context, color);
    CGContextFillPath(context);

    CGContextRestoreGState(context);
}
</code></pre>

<p>the effect like this:
<img src="http://i.stack.imgur.com/7cm8Q.png" alt="enter image description here"></p>
