I cannot make the new onScrollVisibilityChange
work within Lists. Is this an expected limitation or am I doing something wrong? Please see the sample code below.
Thank you!
struct TestView: View {
@State var isTitleVisible: Bool = true
var body: some View {
List {
Section {
Text("Title")
}
.onScrollVisibilityChange { isVisible in
self.isTitleVisible = isVisible
}
Section {
ForEach((0..<100), id: \.self) { i in
Text(i.formatted())
}
/// Changes the background color from green to red once the title is no more visible
.listRowBackground(isTitleVisible ? Color.green : .red)
}
}
}
}
@tomas.bek You should add the modifier on the List instead. You can also use onScrollGeometryChange(for:of:action:) if you need to do custom calculations based off the scroll geometry changes.