> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swiftui/control/scrollview.md).

# ScrollView

{% tabs %}
{% tab title="💾 程式" %}

```swift
struct ContentView: View {
    var body: some View {
        // ⭐️ horizontal scroll view (default = .vertical)
        ScrollView(.horizontal) {
            HStack(spacing: 15) {
                ForEach(0..<20) { i in
                    ZStack {
                        Color.red
                        Text("\(i)")
                    }.frame(width: 50, height: 50)
                }
            }
        }
    }
}
```

{% endtab %}

{% tab title="🖥️ 影片" %}
{% embed url="<https://youtu.be/DbvcD2pQGmE>" %}
tundsdev ⟩ ScrollView & Automatic Scrolling With ScrollViewReader In SwiftUI
{% endembed %}
{% endtab %}

{% tab title="📗 參考" %}

* [ ] Sarun ⟩ [How to use ScrollView in SwiftUI](https://sarunw.com/posts/how-to-use-scrollview-in-swiftui/)
* [ ] Michael Amundsen ⟩ [Every Screen in Your App Should Be a Scrolling View](https://lickability.com/blog/every-screen-in-your-app-should-be-a-scrolling-view/)
  {% endtab %}

{% tab title="👥 相關" %}

* [ScrollVGridForEach](/ios/swiftui/view/layout/grids/scrollvgridforeach.md) - ScrollView + [LazyVGrid](/ios/swiftui/view/layout/grids.md) + [ForEach](/ios/swiftui/view/grouping/foreach.md).
  {% endtab %}
  {% endtabs %}
