In iOS 15, UITableView
adds a separator between a section header and the first cell:
How can I hide or remove that separator?
A few notes:
- The header is a custom view returned from
tableView(_:viewForHeaderInSection:)
. - When looking at the view debugger, I can see that the extra separator is actually a subview of the first cell, which now has a top and a bottom separator.
- Other than setting
tableView.separatorInset
to change the inset of cell separators, this is a completely standard table view with no customizations.
CodePudding user response:
Option 1:
Maybe by using UITableViewCellSeparatorStyleNone
with the table view and replacing the system background view of the cell with a custom view which only features a bottom line?
Option 2: Using hint from https://developer.apple.com/forums/thread/684706
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 150000 // only Xcode 13 needs and can compile this
if (@available(iOS 15.0, *)) {
[self.tableview setSectionHeaderTopPadding:0.0f];
}
#endif
}
CodePudding user response:
There can be two solutions to your problem/
One is
self.tableView.separatorColor = self.tableView.backgroundColor
this is a trick solution, it makes outer lines "disappear" and keep separator lines visible
- second is
change your tableview
type from grouped to plain if grouping not used.
CodePudding user response:
I believe tableView.separatorStyle = .none
should do the trick.
CodePudding user response:
I had a similar issue, but it was due to the table header view suddenly showing as a separator on iOS 15. The only thing that worked for me was:
if #available(iOS 15.0, *)
{
tableView.tableHeaderView = UIView()
}