SwiftUI ScrollView with content frame update closure
问题 I want to have a ScrollView where you can be aware of the content frame changes as the user scrolls (similar to didScroll delegate in UIKit UIScrollView ). With this, you can then perform layout changes based on the scroll behavior. 回答1: I managed to come with a nice solution for this problem by making use of View Preferences as a method to notify layout information upstream in the View Hierarchy. For a very detail explanation of how View Preferences work, I will suggest reading this 3