-3

I don't know about you guys, but when I opened up my project today (the first time since Swift switched to running iOS 15 as the default) my UI looked shockingly different. Most importantly, previously adjacent views inside a ForEach now have some padding in between.

How can we eliminate this? I've included some sample code but I hope we can find a solution that can generalize. The actual problem in my UI has too many moving parts to include here.

struct IntItem: Identifiable {
    let num: Int
    let id = UUID()
  
}


struct ItemView: View {
    var item: IntItem
    
    var body: some View {
        Text(String(item.num))
            .padding(10)
            .border(Color.black)
          
    }
}

struct ContentView: View {
    let array: [IntItem]
    
    var body: some View {
        ScrollView {
            ScrollViewReader { thing in
                ForEach(array) { item in
                    ItemView(item: item)
                }
            }
        }
    }
}


let content = ContentView(array: [IntItem(num: 0), IntItem(num: 1), IntItem(num: 2), IntItem(num: 3)])
matt
  • 515,959
  • 87
  • 875
  • 1,141
John Sorensen
  • 710
  • 6
  • 29

1 Answers1

0

Ok, here's what worked--using a vertical padding of a negative number (in my case 4) on each individual view. I would still like clarification on why this changed with iOS 15.

John Sorensen
  • 710
  • 6
  • 29