views:

443

answers:

1

I am custom drawing text into a custom UITableViewCell, but am struggling in working out how to draw a line to underline text.

I am currently trying to do the following:

CGContextMoveToPoint(context, pt.x, pt.y+sz.height);
CGContextAddLineToPoint(context, pt.x+sz.width, pt.y+sz.height);

but although the code gets called, nothing is actually drawn. I guess I am doing something silly, but I can't work out what it is.

+5  A: 

I've been caught out by the same thing in the past. What you have written just sets up the line to be drawn. You need to call something like this to actually draw the line:

    CGContextStrokePath(context);
Will Harris