table cell custom drawing problem

Discussion in 'iOS Programming' started by chhoda, Nov 24, 2008.

  1. macrumors 6502

    Oct 25, 2008
    Hi All,

    I am doing a custom cell view in IPhone

    my class is inherited from UITableViewCell

    I do custom drawing in drawrect: method.

    every thing is fine, but while selection of row, the text does not display !. Is there a way i will be able to show up the text after selection drawing happens ?

    - (void)drawRect:(CGRect)rect {
    // Drawing code
    [self.desc drawAtPoint:CGPointMake(0,0) withFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];

    CGRect drawRect = CGRectMake(100, 5, 50, 10);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context, 0.5, 1.0, 0.5, 0.8);

    CGContextFillRect(context, drawRect);
  2. macrumors 68030


    Sep 2, 2008
    Maybe you want to draw the text after you fill the rect.
  3. thread starter macrumors 6502

    Oct 25, 2008

    thanks but i am doing my custom drawing in drawRect method which is being called before the drawing of selected rectangle [which is done automatically, when i select a cell.]

  4. macrumors newbie

    Oct 6, 2008
    Instead of writing code in drawRect method you can write code in init method of class referenced from UITableViewCell.

    So whenever you will create the object of UITableviewCell' class it will create a custom cell for your table view.

    And it will work same as default UITableViewCell even if its custom cell. :)
  5. macrumors regular

    Dec 1, 2007
    Based on the code you presented here, in your drawRect routine you draw some text and then promptly cover it up with a filled rectangle. Or so it seems... That's what PhoneyDeveloper was getting at :)

Share This Page