Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Draw a line in UITableViewCell

Tags:

iphone

I need to draw a line in UITableviewcell.

There is any possible way to do this one?

If anybody having any idea about to draw a line in UITableview cell please reply me.

Thanks.

like image 760
Velmurugan Avatar asked Nov 12 '10 14:11

Velmurugan


2 Answers

If the line is horizontal or vertical you could add a black UIView. Like this.

UIView *lineView = [[[UIView alloc] initWithFrame:CGRectMake(0, 25, cell.contentView.bounds.size.width, 1)] autorelease];
lineView.backgroundColor = [UIColor blackColor];
lineView.autoresizingMask = 0x3f;
[cell.contentView addSubview:lineView];

The one above is for one horizontal line. The following code works if you need a vertical line in the middle of the cell

UIView *lineView = [[[UIView alloc] initWithFrame:CGRectMake((cell.contentView.bounds.size.width/2), 0, 1, cell.contentView.bounds.size.height)] autorelease];
like image 189
Matthias Bauch Avatar answered Oct 06 '22 01:10

Matthias Bauch


The easiest way is to take the image of the line and put it in UIImageView and add the image view to cell's content view... don't go all the way to actually 'drawing' it.. it'll be an overkill..

like image 20
Swapnil Luktuke Avatar answered Oct 06 '22 00:10

Swapnil Luktuke