I have an app where the UITableView
's separator inset is set to custom values - Right 0
, Left 0
. This works perfectly in iOS 7.x
, however in iOS 8.0
I see that the separator inset is set to the default of 15
on the right. Even though in the xib files it set to 0
, it still shows up incorrectly.
How do I remove the UITableViewCell
separator margins?
Lukasz answer in Swift:
For any specific cell you want to hide the separator.
In a more compact way than the most voted answer...
}
I just wanted to share an extension I made to remove the margins from the tableview cell separators.
Used in context:
After having seen the answers at floor 3, I tried to figure out what the relationship of setting up the separator between TableView & TableViewCell and did some test. Here are my conclusions:
we can consider that setting the cell's separator to zero has to move the separator in two steps: first step is to set cell's separatorinset to zero. second step is to set cell's marginlayout to zero.
set the TableView's separatorinset and marginlayout can affect the Cell's separatorinset. However, from the test, I find that the TableView's separatorinset seem to be useless, TableView's marginlayout can actually affect cell's marginlayout.
set Cell's PreservesSuperviewLayoutMargins = false, can cut off TableView's marginlayout effect on Cells.
one of the solutions:
Use below code snippet avoid unwanted padding issue for UITableView in IOS 8 & 7.