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.

How to manage multiple sheets in SwiftUI

SwiftUI's sheet modifier enables us to modally present a sheet view when a given condition is true. It's a simple way of modally presenting content and works great when presenting a single sheet from a view. However, things get slightly more complicated when presenting multiple sheets based on different conditions. In his first SwiftUI post, Joe Masilotti describes how he solved the problem of presenting multiple sheets, showing us how he went from an initial solution to a final, more reusable implementation.

swiftui  ios