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.

Building a Multi-platform App with SwiftUI

The Introduction to SwiftUI session at WWDC 2020 included content that focused on using SwiftUI to build multi-platform apps - i.e apps that work on both iOS and macOS. Building such apps can be done by separately building for each platform from a single codebase, or creating a Mac Catalyst app which runs an app built for iPad on macOS. In this post, Rick Wierenga looks at the former, providing a tutorial that shows us how to use a single codebase to build a HackerNews app for each platform.