Drawing in a custom UITableViewCell

Discussion in 'iPhone/iPad Programming' started by Turias, Jan 1, 2009.

  1. macrumors newbie

    Joined:
    Nov 17, 2003
    #1
    Hello,

    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:

    Code:
    - (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. thread starter macrumors newbie

    Joined:
    Nov 17, 2003
    #2
    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