My problem is that i have (in SwiftUI) a ScrollView with an foreach inside. Know when the foreach loads all of my entries i want that the last entry is focused.
I did so
I don't have enough reputation to post a comment yet, so here you go @Dam and @Evert
To scroll to the bottom whenever the number of entries in your ForEach
changes you can also use the same method with a ScrollViewReader
, as mentioned in the answer above, by adding the view modifier onChange
like so:
struct ContentView: View {
let colors: [Color] = [.red, .blue, .green]
var entries: [Entry] = Array(repeating: Entry(), count: 10)
var body: some View {
ScrollView {
ScrollViewReader { value in
ForEach(0..