Horizontales und vertikales ScrollView
Scrollen Sie beliebige Inhalte in jede Richtung.
Horizontales und vertikales ScrollView ist eine kostenlose SwiftUI Academy-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des SwiftUI Academy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der SwiftUI Academy-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
Beyond One Screen
Sometimes your content is taller than the screen. A ScrollView lets users glide past the edges to see it all. 📜
ScrollView {
Text("Lots of content here")
}Vertical by Default
A plain ScrollView scrolls up and down. Wrap a tall VStack inside and everything becomes swipeable.
ScrollView {
VStack {
Text("Top")
Text("Bottom")
}
}Going Horizontal
Pass .horizontal as the axis and your content scrolls left and right instead, great for image carousels.
ScrollView(.horizontal) {
HStack {
Text("One")
Text("Two")
}
}Pick Your Axis
The first argument is the axis: use .vertical, .horizontal, or even both for free, two-way scrolling.
ScrollView([.horizontal, .vertical]) {
BigContent()
}Hiding the Indicator
Set showsIndicators to false to hide the little scroll bar for a cleaner, more designed look.
ScrollView(.horizontal, showsIndicators: false) {
HStack { /* cards */ }
}Content Sizes Itself
A ScrollView only scrolls when its content is bigger than the visible area. Short content just sits still.
Pair with a Stack
Always put a VStack or HStack inside, since a ScrollView holds one child and the stack lines the rest up.
ScrollView {
VStack(spacing: 16) {
Card()
Card()
}
}Free-form vs List
Reach for a ScrollView when you want full layout freedom; a List adds rows and separators for you.
Add Some Padding
Give inner content padding so it does not hug the screen edges as users scroll past it.
ScrollView {
VStack { /* content */ }
.padding()
}Carousels Made Easy
A horizontal ScrollView of cards is the classic recipe for a swipeable carousel of photos or products.
ScrollView(.horizontal) {
HStack {
ForEach(items) { Card($0) }
}
}Smooth and Native
Scrolling feels buttery because ScrollView uses the same engine as the rest of iOS. It just works. ✨
Quick Check
Think about which direction you want to move.
Recap
You learned that a ScrollView reveals overflowing content, scrolls vertically by default, and goes horizontal with an axis. 🎉
Häufig gestellte Fragen
Ist die Lektion „Horizontales und vertikales ScrollView“ kostenlos?
Ja — der vollständige Text von „Horizontales und vertikales ScrollView“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des SwiftUI Academy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der SwiftUI Academy-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Horizontales und vertikales ScrollView“?
Scrollen Sie beliebige Inhalte in jede Richtung. Du übst SwiftUI Academy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um SwiftUI Academy zu starten?
Keine Vorkenntnisse erforderlich. SwiftUI Academy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.
Wie lange dauert die Lektion „Horizontales und vertikales ScrollView“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser SwiftUI Academy-Lektion Code schreiben und ausführen?
Ja. Jede SwiftUI Academy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Horizontales und vertikales ScrollView
- LazyVStack und LazyHStack
- Adaptive Grids mit LazyVGrid
- ScrollView Reader und Anchors