3

Inside my ScrollView, there is LazyVGrid view on the top of other View. After scrolling to bottom, when I scroll to top slowly, I notice that LazyVGrid view disappears for a while. Here is my snapshot (https://imgur.com/gallery/kFsgvgv)

struct ContentView: View {
    var body: some View {
        NavigationView {
            GeometryReader  { proxy in
                ScrollView(.vertical) {
                    LazyVGrid(columns: proxy.size.width > proxy.size.height ? Array(repeating: GridItem(.flexible(), spacing: 15, alignment: .top), count: 2) : Array(repeating: GridItem(.flexible(), alignment: .top), count: 1)) {
                            ForEach(0..<6, id: \.self) { index in
                                    Color(red: Double.random(in: 0...1), green: Double.random(in: 0...1), blue: Double.random(in: 0...1))
                                        .frame(height: 300)
                                        .id(index)
                            }
                        }
                    Color(red: Double.random(in: 0...1), green: Double.random(in: 0...1), blue: Double.random(in: 0...1))
                        .frame(height: 600)
                }
            }
        }
    }
}

My question is how to make LazyVGrid to appear after scrolling to top. Thanks.

Dscyre Scotti
  • 823
  • 3
  • 12

0 Answers0