在 UITableView 中删除 UITableViewCell 之间的行

我用 UITableViewCell创建了一个 UITableView。视图单元格之间有生长线。我想删除这些行,但不想显示出来,但我不知道该怎么做。

我和 Xcode 6.1和 Swift 一起工作。

下面是显示我屏幕的截图:

enter image description here

THX!

77907 次浏览

Within InterfaceBuilder you can set the Separator property to None or do it programmatically by setting the property separatorStyle of your table view to UITableViewCellSeparatorStyleNone.

Using Objective-C, we have:

[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];

for Swift 3:

self.tableView.separatorStyle = .none

for Swift 2:

self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None

OR:

if you are using the InterfaceBuilder, you can set the tableView's Separator property to None enter image description here

Swift 3:

tableView.separatorStyle = UITableViewCellSeparatorStyle.none

You can do it from storyboard like this;

ss

Swift 5 :

cell.selectionStyle = UITableViewCell.SelectionStyle.none

tableView.separatorStyle = .none

when initializing the tableview. It can be set or through the storyboard or nib

Swift 5 Programmatically

private func buildTableView() -> UITableView {
let tableView = UITableView()
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.separatorStyle = .none


return tableView
}