Episode #442

SwiftUI Anchor Preferences

22 minutes
Published on June 16, 2020

This video is only available to subscribers. Get access to this video and 584 others.

Anchors are a way we can refer to the absolute positioning of a view at any level in the view tree. This is useful when you want to have one view surround, underline, or point to another element in the view tree. Combined with GeometryReader, you don't need to worry about converting between coordinate systems like you do in UIKit. Anchors work much like other preferences, with some small differences. In this episode we will build a bar graph view, then use anchors to animate an indicator on the selected item in the graph.

This episode uses Swift 5.3, Xcode 11.5.