97

I've created an UITableView with UITableViewCell. Between the view cells there are grew lines. I want to delete these lines and don't want to show them, but I don't know how.

I work with Xcode 6.1 and Swift.

Here is a screenshot that displays my screen:

enter image description here

THX!

GRme
  • 2,707
  • 5
  • 26
  • 49

9 Answers9

287

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

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
instaable
  • 3,449
  • 2
  • 24
  • 31
  • 6
    In Swift 2 you don't need to actually write `UITableViewCellSeparatorStyle` since that's already the type expected. You may write simply `self.tableView.separatorStyle = .None` for short. – mathielo Oct 13 '15 at 13:11
  • I've removed a wrong edit. What was added had nothing to do with "Swift 4.1", it was related to the OS version, not the language version. Also, it didn't look like a good solution anyway, and should definitely have been posted in its own answer. – Eric Aya Dec 04 '18 at 12:44
  • Separator needs to be set to 'None' for TableView element within Storyboard (not within the Cell/XIB - that's where I was looking incorrectly first place) – marika.daboja Apr 22 '21 at 23:32
16

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.

anka
  • 3,817
  • 1
  • 30
  • 36
8

Swift 3:

tableView.separatorStyle = UITableViewCellSeparatorStyle.none
Marcos Reboucas
  • 3,409
  • 1
  • 29
  • 35
6

You can do it from storyboard like this;

ss

Savas Adar
  • 4,083
  • 3
  • 46
  • 54
4

Swift 5 Programmatically

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

    return tableView
}
MaatheusGois
  • 139
  • 5
1

tableView.separatorStyle = .none

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

0

If you are setting up a lazy tableView, you may want to change the color to clear, seems like an Apple bug where sometimes the style is replaced on layout cycles.

private lazy var tableView: UITableView = {
    let table = UITableView(frame: self.view.bounds, style: .insetGrouped)
    table.separatorStyle = .none // <- HERE
    table.separatorColor = .clear // <- HERE
    table.delegate = self
    table.dataSource = self
    table.estimatedRowHeight = UITableView.automaticDimension
    table.register(UITableView.self, forCellReuseIdentifier: "MyCell")
    return table
}()
Joshua Hart
  • 772
  • 1
  • 21
  • 31
0

I have two ways to remove separator line.

First. Using code for Swift 5

tableView.separatorStyle = .none

Second.If you want to change from storyboard then go to you InterfaceBuilder > Separator > select none.

enter image description here

Priyank Patel
  • 791
  • 8
  • 6
-1

Swift 5 :

cell.selectionStyle = UITableViewCell.SelectionStyle.none
Pratik B
  • 1,599
  • 1
  • 15
  • 32