- August 6, 2025
- Mins Read
A SwiftUI ScrollView that only scrolls if the content doesn’t fit in the View
Requirements iOS 13+
.package(url: “https://github.com/dkk/ScrollViewIfNeeded”, .upToNextMajor(from: “1.0.0”))
Copy /Sources/ScrollViewIfNeeded/ScrollViewIfNeeded.swift
into your project
Import the ScrollViewIfNeeded package to your view:
import ScrollViewIfNeeded
use it like you would use ScrollView
:
ScrollViewIfNeeded {
/* your content */
}
configure it the same way you would configure ScrollView
:
ScrollViewIfNeeded(.horizontal, showsIndicators: false) {
/* your content */
}
or use it as a ViewModifier:
/* your view */
.makeScrollableIfNeeded(.horizontal)
Swift Package Manager The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated ...
Using StoreReader or @Reading in SwiftUI In SwiftUI, there are two ways to observe a Store: using the StoreReader view ...