Reputation:
I want to remove the cell separators in my UITableView
. This is how my simulator currently looks:
I have implemented the following line of code in the viewDidLoad:
method of the .swift
file of the view controller:
self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None
This doesn't seem to be working though.
How do I remove the cell separators?
Here is my cellForRowAtIndexPath:
code:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "Cell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! RestaurantsTableViewCell
// Configure the cell...
cell.nameLabel.text = restaurants[indexPath.row].name
cell.typeLabel.text = restaurants[indexPath.row].type
cell.mainImageView.image = UIImage(named: restaurants[indexPath.row].image)
return cell
}
Upvotes: 3
Views: 2645
Reputation: 6369
All the above should be checked both in code and IB.
Upvotes: 2
Reputation: 3696
I suggest giving the cells a random background color instead of white so you can make sure the cell has padding and it's not part of image. If it didn't work you may try setting the inset to zero using both the table and cell reference. Look at this answer for more explanation.
Remove SeparatorInset on iOS 8 UITableView for XCode 6 iPhone Simulator
Upvotes: 0
Reputation: 389
To hide the separator line you should set the separator insets to zero for each cell. You should add this line in your cellForRowAtIndexPath
:
cell.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
Upvotes: 0