79331807

Date: 2025-01-06 00:29:00
Score: 1.5
Natty:
Report link

Thanks to workingdog's suggestion, I tried using listRowInsets on the header text, which allowed me to adjust the vertical alignment of the header to match the rows. I also experimented with alignmentGuide, but I couldn't get it to work—perhaps I implemented it incorrectly.

The solution that worked for me was using listRowInsets to align the header with the left side of the rows. I adjusted the top and bottom edge insets by trial and error until the alignment looked the same as before. Here’s the code I used:

List {
    Section {
        Text("Row")
        Text("Row")
        Text("Row")
    } header: {
        Text("Header")
            // This is the fix
            .listRowInsets(EdgeInsets(top: 8, leading: 0, bottom: 11, trailing: 0)) 
    }
    .headerProminence(.increased)
}

Image of before and after.

This approach resolved the issue for me, and I hope it helps others facing the same problem.

Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Whitelisted phrase (-1): hope it helps
  • Whitelisted phrase (-1): worked for me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Me too answer (2.5): facing the same problem
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: milkycards