Reputation: 2303
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.
Upvotes: 6
Views: 12069
Reputation: 90127
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];
Upvotes: 23
Reputation: 10475
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..
Upvotes: 2