Drawing in a custom UITableViewCell

Discussion in 'iOS Programming' started by Turias, Jan 1, 2009.

  1. Turias macrumors newbie

    Nov 17, 2003

    I am trying to draw in a custom UITableViewCell, but I can apparently only draw outside the white rounded rectangle that usually defines the cell. Anything I try to draw within that space seems to go behind the white shape. Take the following code, for example:

    - (void)drawRect:(CGRect)rect
    	[super drawRect:rect];
    	CGRect drawRect = CGRectMake(rect.origin.x + 2, rect.origin.y + 2, rect.size.width - 4, rect.size.height - 4);
    	CGContextRef context = UIGraphicsGetCurrentContext(); 
    	CGContextSetRGBFillColor(context, 0.2, 0.5, 0.2, 0.8); 
    	CGContextFillRect(context, drawRect);
    In this case, I can see my green rectangle to the left and to the right of the normal cell, but the white cell itself seems untouched (see the attached image).

    What am I doing wrong? How can I draw within my custom cell? Any help would be greatly appreciated. Thanks!

    Attached Files:

  2. Turias thread starter macrumors newbie

    Nov 17, 2003
    Actually, I think it's because I need to get the UIButton object out of the UITableViewCell and draw in that. Doh! Too much coding, today...

Share This Page