xxxxxxxxxx
ScrollView(.vertical) { // <-- or ScrollView(.horizontal)
VStack(spacing: 20) {
ForEach(0..<20) {
Text("Row \($0)")
}
}
}
xxxxxxxxxx
import SwiftUI
struct ContentView: View {
var body: some View {
ScrollView(.horizontal) {
HStack {
// Add your views here
Text("View 1")
.frame(width: 200, height: 200)
.background(Color.red)
Text("View 2")
.frame(width: 200, height: 200)
.background(Color.green)
Text("View 3")
.frame(width: 200, height: 200)
.background(Color.blue)
// ... add more views if needed
}
.padding()
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}