SwiftUI Weekly - Issue #192
The curated collection of links about SwiftUI. Delivered every Monday.
Reading
Mastering ScrollView in SwiftUI. Scroll Offset
WWDC 24 is over, and I decided to start writing posts about new features in the upcoming iteration of the SwiftUI framework. Apple continues filling gaps this year by introducing more granular control over the scroll position. This week, we will learn how to manipulate and read the scroll offset.
Mastering ScrollView in SwiftUI. Scroll Geometry
The ScrollPosition type is all you need to programmatically read or change the scroll position. Still, it doesn’t provide enough information when a user interacts with a scroll view using gestures. SwiftUI solves this problem by introducing the new ScrollGeometry type.
Wrapping text within another view in SwiftUI
When designing user interfaces in SwiftUI, we might encounter situations where we must wrap text within another view, such as an image or a shape. This can be effectively achieved using the overlay()modifier. Let's explore this concept with an example and compare it with using a ZStack
.
Using TextRenderer to create highlighted text
TextRenderer
is a new protocol introduced at WWDC 2024 which lets us enhance how text is rendered in SwiftUI. In this small post, I want to show how to create a view that enables you to highlight certain parts of a given String. Previously this was primarily done using NSAttributedString
, but with TextRenderer
it is now possible to do the same in a pure SwiftUI way.
Consolidated ViewState
Managing multiple states in SwiftUI views can be complex and error-prone. This post addresses the issue by introducing a consolidated generic ViewState enum, simplifying state management, reducing bugs, and enhancing maintainability.
Book
SwiftUI and Accessibility: Creating Inclusive iOS Applications
Are you an iOS developer eager to create apps that everyone can use and enjoy? Dive into "SwiftUI and Accessibility: Creating Inclusive iOS Applications," your definitive guide to building inclusive, user-friendly applications with SwiftUI.
Videos
My Favorite SwiftUI Updates in iOS 18
WWDC 2024 introduced awesome new additions to SwiftUI in iOS 18. In this video I highlight a few of my favorites including Mesh Gradients, zoom transitions in NavigationStacks, SF Symbols 6 and the new animations, floating TabView and custom sheet sizes on iPadOS, and date reference Text formatting.