One Logo Pool Ball
SwiftUI · IOS API REFERENCE

ScrollView

struct · iOS 13.0+ · SDK 27.1

nonisolated struct ScrollView<Content> where Content : View

A scrollable view. The scroll view displays its content within the scrollable content region. As the user performs platform-appropriate scroll gestures, the scroll view adjusts what portion of the underlying content is visible. `ScrollView` can scroll horizontally, vertically, or both, but does not provide zooming functionality. In the following example, a `ScrollView` allows the user to scroll through a ``VStack`` containing 100 ``Text`` views. The image after the listing shows the scroll view's temporarily visible scrollbar at the right; you can disable it with the `showsIndicators` parameter of the `ScrollView` initializer. var body: some View { ScrollView { VStack(alignment: .leading) { ForEach(0..<100) { Text("Row \($0)") } } } } ![A scroll view with a series of vertically arranged rows, reading Row 1, Row 2, and so on. At the right, a scrollbar indicates that this is the top of the scrollable area.](SwiftUI-ScrollView-rows-with-indicator.png) ### Controlling Scroll Position You can influence where a scroll view is initially scrolled by using the ``View/defaultScrollAnchor(_:)`` view modifier. Provide a value of ``UnitPoint/center`` to have the scroll view start in the center of its content when a scroll view is scrollable in both axes. ScrollView([.horizontal, .vertical]) { // initially centered content } .defaultScrollAnchor(.center) Or provide an alignment of ``UnitPoint/bottom`` to have the scroll view start at the bottom of its content when a scroll view is scrollable in its vertical axes. ScrollView { // initially bottom aligned content } .defaultScrollAnchor(.bottom) After the scroll view initially renders, the user may scroll the content of the scroll view. To perform programmatic scrolling, wrap one or more scroll views with a ``ScrollViewReader``.

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

3 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

ScrollView.init(_:showsIndicators:content:)

callback cannot propagate synchronous failure

ScrollView.body

This protocol needs associated types that cannot yet cross the bridge.

ScrollView.init(_:content:)

callback cannot propagate synchronous failure

All SwiftUI types →