VesselWheel

NavigationView with section in Form{} 본문

Xcode Study

NavigationView with section in Form{}

JasonYang 2023. 10. 18. 17:21

 

 

 

 

import SwiftUI

 

struct ContentView: View {

    @State private var username: String = ""

    @State private var isPrivate: Bool = true

    @State private var notifications: Bool = false

    @State private var previewIndex = 0

    let previewOptions: Array<String> = ["Always", "When Unlocked", "Never"]

    

    var body: some View {

        /*

        Form{

            TextField("Username", text: self.$username)

            Toggle(isOn: self.$isPrivate){

                Text("Private Account")

            }

        }*/

        NavigationView{

            Form{

                Section(header: Text("PROFILE")){

                    TextField("Username", text: self.$username)

                    Toggle(isOn: self.$isPrivate){

                        Text("Private Account")

                    }

                }

                Section(header: Text("NOTIFICATIONS")){

                    Toggle(isOn: self.$notifications){

                        Text("Enabled")

                    }

                    Picker(selection: self.$previewIndex, label: Text("Show Previews")){

                        ForEach(0..<previewOptions.count){ index in

                            Text(self.previewOptions[index])

                        }

                    }

                }

            }

        }

    }

}

 

struct ContentView_Previews: PreviewProvider {

    static var previews: some View {

        ContentView()

    }

}

'Xcode Study' 카테고리의 다른 글

Xcode 자동 들여쓰기 //Re-Intent(Ctl + i or cmd ][ )  (0) 2023.10.19
cocoa pods 사용법과 터미널 내용  (1) 2023.10.18
count : index with VStack  (0) 2023.10.18
NavigationView  (0) 2023.10.18
단추 늘이기, 줄이기  (0) 2023.10.18