0Pricing
SwiftUI Academy · Lección

ScrollView horizontal y vertical

Desplace contenido arbitrario en cualquier dirección.

ScrollView horizontal y vertical es una lección gratuita de SwiftUI Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de SwiftUI Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de SwiftUI Academy incluye 4 lecciones en total.

Partes de esta lección aún no han sido traducidas y se muestran en inglés.

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. 🎉

Preguntas frecuentes

¿La lección «ScrollView horizontal y vertical» es gratis?

Sí — el texto completo de «ScrollView horizontal y vertical» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de SwiftUI Academy, actualiza a CoddyKit PRO. El curso de SwiftUI Academy incluye 4 lecciones en total.

¿Qué aprenderé en «ScrollView horizontal y vertical»?

Desplace contenido arbitrario en cualquier dirección. Practicas SwiftUI Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.

¿Necesito experiencia previa para empezar SwiftUI Academy?

No se requiere experiencia previa. SwiftUI Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.

¿Cuánto tiempo toma la lección «ScrollView horizontal y vertical»?

La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.

¿Puedo escribir y ejecutar código en esta lección de SwiftUI Academy?

Sí. Cada lección de SwiftUI Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.

Todas las lecciones de este curso

  1. ScrollView horizontal y vertical
  2. LazyVStack y LazyHStack
  3. Grids adaptativas con LazyVGrid
  4. ScrollView Reader y anchors
← Volver a SwiftUI Academy