Open DaisukeNagata opened 4 years ago
this is code
struct ContentView: View {
var body: some View {
ScrollViewReader { scrollOffset in
ScrollView {
LazyVStack(alignment: .center) {
ForEach(1...100, id: \.self) {
Text("Row \($0)")
}
.onChange(of: /*@START_MENU_TOKEN@*/"Value"/*@END_MENU_TOKEN@*/) { value in
print(scrollOffset.scrollTo(77, anchor: .center))
}
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
It will be the coordinates of the specified location.
https://developer.apple.com/documentation/swiftui/scrollviewreader