One Logo Pool Ball
SwiftUI · IOS API REFERENCE

PagingScrollTargetBehavior

struct · iOS 17.0+ · SDK 27.1

struct PagingScrollTargetBehavior

The scroll behavior that aligns scroll targets to container-based geometry. In the following example, every view in the lazy stack is flexible in both directions and the scroll view settles to container-aligned boundaries. ScrollView { LazyVStack(spacing: 0.0) { ForEach(items) { item in FullScreenItem(item) } } } .scrollTargetBehavior(.paging)

Members (3)

method · iOS 17.0+

updateTarget

TypeScript
updateTarget(target: _SwiftUICore_ScrollTarget, context: ScrollTargetBehaviorContext): { $ret: null; $out: { "target": _SwiftUICore_ScrollTarget } }
Swift declaration
func updateTarget(_ target: inout ScrollTarget, context: PagingScrollTargetBehavior.TargetContext)

Updates the proposed target that a scrollable view should scroll to. The system calls this method in two main cases: - When a scroll gesture ends, it calculates where it would naturally scroll to using its deceleration rate. The system provides this calculated value as the target of this method. - When a scrollable view's size changes, it calculates where it should be scrolled given the new size and provides this calculates value as the target of this method. You can implement this method to override the calculated target which will have the scrollable view scroll to a different position than it would otherwise.

Omit the output parameters from the call. The result contains $ret and $out, with target inside $out.

method · iOS 18.4+

properties

TypeScript
properties(context: ScrollTargetBehaviorPropertiesContext): ScrollTargetBehaviorProperties
Swift declaration
func properties(context: PagingScrollTargetBehavior.PropertiesContext) -> PagingScrollTargetBehavior.Properties

Properties of this behavior

init · iOS 17.0+

init

TypeScript
static init(): PagingScrollTargetBehavior
Swift declaration
init()

Creates a paging scroll behavior.

Skipped declarations

No declarations were skipped in this snapshot.

All SwiftUI types →