1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | / / / / ContentView.swift / / Testapp / / / / Created by Cairocoders / / import SwiftUI struct ContentView: View { var body: some View { VStack { Divider() ScrollView(.horizontal) { HStack(spacing: 10 ) { ForEach( 0. .< 21 ) { index in NumberView1to20(label: "\(index)" ) } }.padding() }.frame(height: 100 ) Divider() Spacer() } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } struct NumberView1to20: View { @State var label: String var body: some View { ZStack { Circle() .fill(Color.green) .frame(width: 70 , height: 70 ) Text(label) .foregroundColor(.white) } } } |
article
Monday, May 24, 2021
SwiftUI Horizontal scroll or horizontal list view
SwiftUI Horizontal scroll or horizontal list view