Reputation: 7155
I'm looking for a way to completely remove the separator line in a UITableView when in the plain mode. This is done automatically in grouped, but this also changes the dimensions of the table in a way that is hard to measure. I have set the seperator line color to colorClear. But this does not completely solve the problem.
As I am trying to draw a custom background view in the cells, and I want the cells to be seamless, the one pixel line that remains in-between is causing me problems. Is there a more elegant workaround then using a grouped view and then stretching it?
Upvotes: 228
Views: 126548
Reputation: 9082
You can do this with the UITableView
property separatorStyle
. Make sure the property is set to UITableViewCellSeparatorStyleNone
and you're set.
Objective-C
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
In Swift (prior to 3)
tableView.separatorStyle = .None
In Swift 3/4/5
tableView.separatorStyle = .none
Upvotes: 456
Reputation: 1213
In interface Builder set table view separator "None"
and those separator lines which are shown after the last cell can be remove by following approach. Best approach is to assign Empty View to tableView FooterView in viewDidLoad
self.tableView.tableFooterView = UIView()
Upvotes: 10
Reputation: 1611
There is bug a iOS 9 beta 4: the separator line appears between UITableViewCell
s even if you set separatorStyle
to UITableViewCellSeparatorStyleNone
from the storyboard. To get around this, you have to set it from code, because as of now there is a bug from storyboard. Hope they will fix it in future beta.
Here's the code to set it:
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
Upvotes: 5
Reputation: 3523
In the ViewDidLoad Method, you have to write this line.
tableViews.separatorStyle = UITableViewCellSeparatorStyleNone;
This is working Code.
Upvotes: 2
Reputation: 71
In your viewDidLoad
:
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
{
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
Upvotes: 1
Reputation: 26048
You can do this in the storyboard / xib editor as well. Just set Seperator to none.
Upvotes: 64
Reputation: 371
I still had a dark grey line after attempting the other answers. I had to add the following two lines to make everything "invisible" in terms of row lines between cells.
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.separatorColor = [UIColor clearColor];
Upvotes: 18
Reputation: 4798
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
}
Upvotes: 62