-2

I’m working on a screen that uses a single SwiftUI List composed of:

  1. a top block (statistics, month picker, year selector, total, Entrata/Uscita picker).
  2. a list of transactions grouped by day, each group inside its own Section.
  3. each row is a fully custom card with rounded corners (RoundedCornerShape)

screenshot

I’m correctly removing all separators using:

.listRowSeparator(.hidden)
.listSectionSeparator(.hidden)
.scrollContentBackground(.hidden)
.listStyle(.plain)

Each row is rendered like this:

TransazioneSwipeRowView(...)
.listRowInsets(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
.listRowBackground(Color.clear)

However, I still see thin horizontal lines appearing between:

  • the search bar and the top block
  • the top block and the start of the list
  • between rows inside the grouped section
  • sometimes at the bottom of a Section

These lines are NOT:

  • Divider()
  • system separators
  • backgrounds
  • row borders

They seem to be “ghost lines” automatically generated by SwiftUI’s List when multiple consecutive rows or sections are present.

Goals

I want to remove these horizontal “ghost lines” completely while keeping:

  • native SwiftUI List
  • native scroll behavior
  • swipe-to-delete support
  • grouping by Section
  • custom card-like rows with rounded corners

What I already tried

  • .plain, .grouped, .insetGrouped list styles
  • .listRowSeparator(.hidden) and .listSectionSeparator(.hidden)
  • .scrollContentBackground(.hidden)
  • clearing all list and row backgrounds
  • adjusting/removing all padding and insets
  • Spacer(minLength: 0) tests
  • rebuilding the layout using ScrollView + LazyVStack (this works perfectly — no lines — but loses native swipe-to-delete)

There are no Divider() calls, and no background colors that could generate borders. The lines seem to be drawn by SwiftUI internally.

Question

Is this a built-in behavior of SwiftUI’s List in .plain style when using multiple custom rows? Or is there an officially supported way to eliminate these lines entirely?

More specifically, is there a recommended combination of modifiers to achieve:

  • a List with grouped Sections
  • fully custom rows with rounded corners
  • no horizontal separators at all, even in the empty gaps between sections?

Any guidance, documented workarounds, WWDC references, or official recommendations would be greatly appreciated.

2
  • Problem solved! Thanks to user darkpaw I was able to fix it. See the full solution on the Apple Developer Forum. Thanks everyone! Commented 5 hours ago
  • 1
    Please don't edit your question as "solved". The proper way is to post an actual answer below with all relevant details. Commented 5 hours ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.