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.
My code
My question is how to prevent LazyVGrid not to be destroyed after disappearing. Thanks.
My code
Code Block swift struct ContentView: View { var body: some View { NavigationView { GeometryReader { proxy in ScrollView(.vertical) { LazyVStack { 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: 400) } } } } } }
My question is how to prevent LazyVGrid not to be destroyed after disappearing. Thanks.