SwiftUI ScrollView offset

When using scrollable view types, it's common to want to access the content offset. The content offset is the point at which the origin of the content view is offset from the origin of the scroll view. While UIKit's UIScrollView provides contentOffset, allowing us to read/write to this property, SwiftUI's ScrollView does not provide such a property. Instead, SwiftUI provides the ScrollViewReader type, which can be used in place of direct access to a content offset property. However, there might still be times when we want to directly access the content offset of a SwiftUI ScrollView, and in this post, Federico Zanetello shows us how to do that.

SwiftUI: Bridging UIKit with ScrollViewReader and DragGesture

SwiftUI includes a ScrollView type, which is similar in function to its UIKit counterpart. However, until recently, SwiftUI was unable to programmatically scroll to a particular offset in the ScrollView. With iOS 14, this is now possible, and in this post, Federico Zanetello uses this new ability, together with DragGesture, to implement his own version of an index list.