Xetius
Xetius

Reputation: 46924

Drawing a line in a custom UITableViewCell

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.

Upvotes: 2

Views: 1204

Answers (1)

Will Harris
Will Harris

Reputation: 21695

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);

Upvotes: 6

Related Questions