views:

40

answers:

1

Hey all,

i have little problem with my code. I want to add a footer to a uitableview-section, but that's not my problem.

My problem is that i want to have rounded corners on my footer-view, but not on all corners, just the two on the bottom. But the corners are just too dark and i don't know why...

Heres my code:

- (void)drawRect:(CGRect)rect {
    float radius = 10.0f;
    CGContextRef context = UIGraphicsGetCurrentContext();   

    CGFloat strokeColorArray[4] = {0.35f,0.35f,0.35f,1.0f}; 
    CGContextSetStrokeColor(context, strokeColorArray);
    CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1);
    CGContextSetLineWidth(context, 1.0);        

    CGContextBeginPath(context);

    CGContextMoveToPoint(context, CGRectGetMinX(rect), CGRectGetMinY(rect));
    CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMinY(rect));
    CGContextAddArc(context, CGRectGetMaxX(rect) - radius, CGRectGetMaxY(rect) - radius, radius, 0, M_PI / 2, 0);
    CGContextAddArc(context, CGRectGetMinX(rect) + radius, CGRectGetMaxY(rect) - radius, radius, M_PI / 2, M_PI, 0);
    CGContextClosePath(context);

    CGContextFillPath(context); 


    CGContextMoveToPoint(context, CGRectGetMaxX(rect), CGRectGetMinY(rect));
    CGContextAddArc(context, CGRectGetMaxX(rect) - radius, CGRectGetMaxY(rect) - radius, radius, 0, M_PI / 2, 0);
    CGContextAddArc(context, CGRectGetMinX(rect) + radius, CGRectGetMaxY(rect) - radius, radius, M_PI / 2, M_PI, 0);
    CGContextAddLineToPoint(context, CGRectGetMinX(rect), CGRectGetMinY(rect));

    CGContextDrawPath(context, kCGPathStroke);
}

Here's a picture of my problem: http://img195.imageshack.us/img195/9834/bildkw.png

Can you see the darker corners? How can i fix that?

Thank you

Sebastian

+1  A: 

There's a couple things you can try. One is to change the radius of the corners. Another is to add some code to make sure that you draw lines on the inside of the rectangle and instead of centering the lines on the edges. To do that, you would have to inset the rect by half of the line width, or 0.5 pixels in this case.

lucius
Insetting the rectangle by 0.5 pixel solved my problem. Thank you!
antihero