SwiftUI Weekly - Issue #234
The curated collection of links about SwiftUI. Delivered every Monday.
Deprecating your own convenience API
Almost after every major update of iOS, we got new APIs that we use on the most recent platform but can’t use on the previous one. Usually, I solve this kind of thing by introducing my own convenience code that runs new APIs on the available versions and my custom implementation or stubs on old platform versions.
Making a SwiftUI sheet automatically size to fit its content
An iOS sheet defaults to covering around half the screen, and while you can specify custom detents, it’s not enough. This article shows you how to easily make a sheet size to fit its content.
A floating card using safeAreaBar
The safeAreaBar view modifier is another way to manage the safe area of the view. The safeAreaBar view modifier allows you to shift the safe area of the view by placing another view inside the original safe area of the view.
ContentUnavailableView in SwiftUI
SwiftUI has steadily evolved from a declarative UI framework into a platform with thoughtful, production ready UI components. One of the most underrated additions is ContentUnavailableView.
Modern SwiftUI APIs for programmatic scrolling
iOS 17 introduced scrollPosition(id:anchor:), replacing the proxy approach with a state binding. iOS 18 went further, introducing a more capable scrollPosition(_:anchor:) modifier and the ScrollPosition struct that expresses position as an identifier, an edge, or a raw offset. iOS 18 also added onScrollGeometryChange(for:of:action:), which provides continuous access to the scroll view's geometry as the user scrolls.
