xcode UITableView - 单元格之间的线条
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7231268/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UITableView - Lines Between Cells
提问by Baub
I have a UITableView
that has cells of which, for this example, let's say only the top two are filled. For the rest of the cells going down the list there are still separator lines.
我有一个UITableView
单元格,在这个例子中,假设只有前两个被填充。对于列表中的其余单元格,仍有分隔线。
Is there a way to turn the lines off where there are empty cells but keep them on to separate cells that contain information?
有没有办法在有空单元格的地方关闭线条,但保持它们打开以分隔包含信息的单元格?
回答by PeyloW
No there is no built in support for this.
不,没有对此的内置支持。
You could turn off the cells on the table view with:
您可以使用以下命令关闭表格视图上的单元格:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
And then draw the separator lines in your own UITableViewCell
subclasses that you use for the rows.
然后在您自己UITableViewCell
用于行的子类中绘制分隔线。
回答by Ekkstein
Another simple hack is to add this to the UITableViewControllers viewDidLoad Method:
另一个简单的技巧是将它添加到 UITableViewControllers viewDidLoad 方法中:
self.tableView.tableFooterView = [UIView new];
回答by Rajan Maheshwari
One more way is do just write the line in viewdidLoad
另一种方法是在viewdidLoad 中写一行
self.myTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];