Reputation: 8952
In my app I'm using a UITableView
which consists of multiple headers and one or two rows for each header. Each cell features two UITableViewRowActions
. My problem is, that whenever these row actions are animated out, a strange separator appears between the cell and the header underneath.
I've tried turning off the default separators, and using a custom separator instead, but for some reason I actually need to use the default separators.
In the next step I tried to disable the separator only for those cells which are on top of the next header, like this, but it didn't work:
if #available(iOS 9.0, *) {
tableView.cellLayoutMarginsFollowReadableWidth = false
}
cell.layoutMargins = UIEdgeInsetsZero
cell.preservesSuperviewLayoutMargins = false
cell.separatorInset.left = self.view.frame.size.width
To help you gain an impression of the issue, I've created three screenshots that show the strange behaviour:
Before:
While displaying row actions:
After dismissing row actions using tableView.setEditing(false, animated: true)
:
Do you have any idea how I can remove this strange separator line?
Upvotes: 2
Views: 591
Reputation: 8952
I finally found a relatively clean solution to fix this issue - I just add a "line fix" view to every header view, that will overlay the strange separator. Since it seems to be an Apple bug, that's probably the best workaround.
Here's the code:
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let view = UITableViewHeaderFooterView()
let lineFix = UIView(frame: CGRect(x: 0, y: -0.5, width: tableView.frame.size.height, height: 0.5))
lineFix.backgroundColor = UIColor.groupTableViewBackgroundColor()
view.addSubview(lineFix)
return view
}
Upvotes: 3