값을 입력하는 화면
스크롤도 자동으로 처리됨
struct Form: View {
@State private var email = ""
@State private var password = ""
@State private var address = ""
@State private var age = 0
@State private var receiveEmail = false
var body: some View {
Form {
TextField("Email", text: $email)
SecureField("Password", text: $password)
TextField("Address", text: $aaddress)
Stepper("Age", value: $age)
Toggle(isOn: $receiveEmail, label : { Text("Receive Email") })
Button("확인") {
}
.padding()
.frame(maxWidth: .infinity)
}
}
}
구역을 분리하고 싶다면 Section으로 나누면 된다.
struct Form: View {
@State private var email = ""
@State private var password = ""
@State private var address = ""
@State private var age = 0
@State private var receiveEmail = false
var body: some View {
Form {
Section{
TextField("Email", text: $email)
SecureField("Password", text: $password)
TextField("Address", text: $aaddress)
}
Stepper("Age", value: $age)
Toggle(isOn: $receiveEmail, label : { Text("Receive Email") })
Button("확인") {
}
.padding()
.frame(maxWidth: .infinity)
}
}
}