简体   繁体   English

如何在UITableViewCell中绘制一条线

[英]How to Draw a line in UITableViewCell

I need to draw a line in UITableviewcell. 我需要在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. 如果有人想知道在UITableview单元格中划线,请回复我。

Thanks. 谢谢。

If the line is horizontal or vertical you could add a black UIView. 如果线条是水平线或垂直线,您可以添加黑色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];

最简单的方法是获取该行的图像并将其放入UIImageView并将图像视图添加到单元格的内容视图中...不要一直到实际“绘制”它...它将是一种矫枉过正。 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM