views:

67

answers:

0

Hi,

I have some problems drawing some custom content over a UITableView. What I did was subclass UITableView and overwrite the -(void)drawRect method something like this:

- (void)drawRect:(CGRect)rect
{
    CGContextRef ctx = UIGraphicsGetCurrentContext();

    [super drawRect:rect];

    CGContextSetRGBFillColor(ctx, 255, 0, 0, 1.0f); 
    CGContextFillRect(ctx, CGRectMake(10, 10, 10, 10));
}

The problem is that i see my red rectangle but it's underneath the table view cells. Even if I comment the [super drawRect:rect] call in the method above, the cells will still display.

My guess is that internally whoever calls the drawRect method for the tableview, draws the cells afterwards, meaning the overwriting drawRect is not enough because the cells will always be drawn afterwards.