Xcode Study

count : index with VStack

JasonYang 2023. 10. 18. 17:18

 

import SwiftUI

 

struct ContentView: View {

    var body: some View {

        Form{

            VStack {

                ScrollView(){

                    VStack{

                        ForEach(1 ..< 31

                        ){ index in

                            Text("Count : \(index)")

                                .font(.largeTitle)

                        }

                    }

                    // .infinity : VStack 이 가지는 최대한 너비

                    //                 ㄴ 화면 너비

                    .frame(maxWidth: .infinity)

                }

                .frame(height: 200)

                .background(.orange)

                

                Divider()

                

                ScrollView(.horizontal, showsIndicators: false){

                    HStack{

                        ForEach(1 ..< 31

                        ){ index in

                            Text("Count : \(index)")

                                .font(.largeTitle)

                        }

                    }

                }

                .frame(height: 200)

                .background(.pink)

                

            }

        }

 

    }

}

 

struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}