如何在UITableViewCell中画一条线 [英] How to Draw a line in UITableViewCell

查看:72
本文介绍了如何在UITableViewCell中画一条线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在UITableviewcell中画一条线.

I need to draw a line in UITableviewcell.

有什么方法可以做到这一点?

There is any possible way to do this one?

如果有人想在UITableview单元格中画一条线,请回复我.

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

谢谢.

推荐答案

如果线条是水平或垂直,则可以添加黑色的UIView.这样.

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

这篇关于如何在UITableViewCell中画一条线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆