Declaration
compose().scrollTargetLayout({
isEnabled?: boolean,
})nonisolated func scrollTargetLayout(isEnabled: Bool = true) -> some ViewParameters
options.isEnabledboolean
Discussion
This modifier works together with the
ViewAlignedScrollTargetBehavior to ensure that scroll views align
to view based content.
Apply this modifier to layout containers like LazyHStack or
VStack within a ScrollView that contain the main repeating
content of your ScrollView.
ScrollView(.horizontal) {
LazyHStack(spacing: 10.0) {
ForEach(items) { item in
ItemView(item)
}
}
.scrollTargetLayout()
}
.scrollTargetBehavior(.viewAligned)A scroll target layout ensures that any target layout nested within the primary one will not also become a scroll target layout.
LazyHStack { // a scroll target layout
VStack { ... } // not a scroll target layout
LazyHStack { ... } // also not a scroll target layout
}
.scrollTargetLayout()See also
More in Layout.
- alignmentGuideSets the view's vertical alignment.
- aspectRatioConstrains this view's dimensions to the specified aspect ratio.
- containerCornerOffsetAdjusts the view's layout to avoid the container view's corner insets for the specified edges.
- containerRelativeFramePositions this view within an invisible frame with a size relative to the nearest container.
- controlSizeSets the size for controls within this view.
- defaultScrollAnchorAssociates an anchor to control which part of the scroll view's content should be rendered by default.
- dynamicTypeSizeSets the Dynamic Type size within the view to the given value.
- fixedSizeFixes this view at its ideal size.
- flipsForRightToLeftLayoutDirectionSets whether this view mirrors its contents horizontally when the layout direction is right-to-left.
- framePositions this view within an invisible frame.
- geometryGroupIsolates the geometry (e.g. position and size) of the view from its parent view.
- gridCellAnchorSpecifies a custom alignment anchor for a view that acts as a grid cell.