How to find if scrollview content has reached its end of the content in SwiftUI

Viewed 923

I m developing an app in SwiftUI. In of my app screens I have a scrollView where I want to find if scrollView has reached its bottom or end of scroll. I m able to find content offset using GeometryReader but could not find a way to figure out the scroll end.

Below is the code I have tried:

    var body: some View {
        ScrollView {

            GeometryReader { geometry -> Text in
                print("\(self.offsetValue)")
                DispatchQueue.main.async {
                    self.offsetValue = geometry.frame(in: .global).origin.y
                }

            }

        } 
 }

Thanks in advance!!

1 Answers

One way is using UIScrollview in UIViewRepresentable that you can achieve the scrollview delegation methods.

also suggesting to read this article that can you understand how it works

Related