| 代码折叠/展开: command + option + 左箭头/右箭头 //
//  ContentView.swift
//  TaskApp
//
//  
import SwiftUI
struct ContentView: View {
    let tags = ["家","学校","公司"]
    @State var showAlert = false
    @State var name: String = ""
    @State var phone: String = ""
    @State var address: String =  ""
    @State var tagIndex = 0
    var body: some View {
        NavigationView{
            Form{
                Section(header:Text("内容")){
                    HStack{
                        Text("收货人:")
                        TextField("输入收货人姓名", text: $name)
                    }
                    HStack{
                        Text("手机:")
                        TextField("输入收货手机", text: $phone)
                    }
                    HStack{
                        Text("联系地址:")
                        TextField("输入收货人联系地址", text: $address)
                    }
                }
                Section(header:Text("标题")){
                    Picker("XX", selection: $tagIndex) {
                        ForEach(0..<tags.count,id:\.self){
                            tag in
                            Text(tags[tag])
                        }
                    }.pickerStyle(SegmentedPickerStyle())
                }
                
                Section{
                    Button("填好了"){
                        self.showAlert = true
                    }.alert(isPresented: $showAlert){
                        Alert(title: Text("确认地址"), message: Text("ssxsxsxsx"), dismissButton: .default(Text("确认了"))
                        )
                    
                    }
                    
                }
            
               
            }
            .navigationBarTitle("新增收货地址")
        }
      
    }
}
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
 |