From cbb3677214ed7b5757520585f95c8987c7eef52b Mon Sep 17 00:00:00 2001 From: Sophia Lee Date: Wed, 17 Jul 2024 16:24:40 -0700 Subject: [PATCH] New method for separator hiding (#2068) (#2070) (cherry picked from commit 30b8885f5d563b3a0b32f0c42a203900c2065340) Co-authored-by: Lukas Capkovic <3610850+lcapkovic@users.noreply.github.com> --- ios/FluentUI/Other Cells/ActionsCell.swift | 8 ++++++++ ios/FluentUI/Table View/TableViewCell.swift | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/ios/FluentUI/Other Cells/ActionsCell.swift b/ios/FluentUI/Other Cells/ActionsCell.swift index 8b1f96982a..c254dd78c5 100644 --- a/ios/FluentUI/Other Cells/ActionsCell.swift +++ b/ios/FluentUI/Other Cells/ActionsCell.swift @@ -186,6 +186,14 @@ open class ActionsCell: UITableViewCell, TokenizedControlInternal { verticalSeparator.frame = CGRect(x: left, y: 0, width: verticalSeparator.frame.width, height: frame.height) } + // A hacky way to hide the system separator by squeezing it just enough to have zero width. + // This is the only known way to hide the separator without making the UITableView do it for us. + let boundsWidth = bounds.width + let targetSystemSeparatorInset = UIEdgeInsets(top: 0, left: boundsWidth, bottom: 0, right: 0) + if separatorInset.left < boundsWidth { + separatorInset = targetSystemSeparatorInset + } + layoutHorizontalSeparator(topSeparator, with: topSeparatorType, at: 0) layoutHorizontalSeparator(bottomSeparator, with: bottomSeparatorType, at: frame.height - bottomSeparator.frame.height) } diff --git a/ios/FluentUI/Table View/TableViewCell.swift b/ios/FluentUI/Table View/TableViewCell.swift index 134294d746..c1115b01f8 100644 --- a/ios/FluentUI/Table View/TableViewCell.swift +++ b/ios/FluentUI/Table View/TableViewCell.swift @@ -1437,6 +1437,14 @@ open class TableViewCell: UITableViewCell, TokenizedControlInternal { layoutContentSubviews() contentView.flipSubviewsForRTL() + // A hacky way to hide the system separator by squeezing it just enough to have zero width. + // This is the only known way to hide the separator without making the UITableView do it for us. + let boundsWidth = bounds.width + let targetSystemSeparatorInset = UIEdgeInsets(top: 0, left: boundsWidth, bottom: 0, right: 0) + if separatorInset.left < boundsWidth { + separatorInset = targetSystemSeparatorInset + } + layoutSeparator(topSeparator, with: topSeparatorType, at: 0) layoutSeparator(bottomSeparator, with: bottomSeparatorType, at: frame.height - bottomSeparator.frame.height) }