Trevor Whittingham 12/10/2024

Replace Scroll Geometry Hacks With SwiftUI's iOS 18 Scroll APIs

Read Original

This article discusses how iOS 18 introduces new SwiftUI scroll APIs such as onScrollGeometryChange, onScrollVisibilityChange, and ScrollPosition, which replace the traditional workaround of using GeometryReader and PreferenceKeys to track scroll offset. It explains how to use these APIs to implement features like showing a back-to-top button, detecting scroll threshold, and pagination, with code examples. The APIs are available across Apple platforms and simplify scroll-related UI logic.

Replace Scroll Geometry Hacks With SwiftUI's iOS 18 Scroll APIs

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

No top articles yet