当前位置: 首页>编程语言>正文

SWIFTUI PICKER $ FORM

//
//  OrderHidstory.swift
//  Sandwichs
//
//  Created by Mac on 2020/10/27.
//

import SwiftUI

struct OrderHidstory: View {
    
    @State var intVale = 0
    @State var pickVale = "请选择"
    
    var pickArr:Array<String> = ["第一项","第二项","第三项"]
    
    var body: some View {
        NavigationView{
            Form {
                        Text("text")
                        Section {
                            Text("Section")
                            Button(action: {}, label: {
                                Text("Button")
                            })
                            Stepper("你好\(intVale)", value: $intVale)
                            
                        }
                        
                        Section(header: Text("Picker")){
                            Picker("\(pickVale)", selection: $pickVale) {
                                ForEach(pickArr, id: \.self) { str in
                                    Text(str).tag(str)
                                    
                                }
                            }
                            .pickerStyle(MenuPickerStyle())
                        }
                        
                        Section(header:Text("Picker 2")) {
                            Picker(selection: $pickVale, label: Text("Picke \(pickVale)"), content: /*@START_MENU_TOKEN@*/{
                                ForEach(self.pickArr, id: \.self) { str in
                                    Text(str).tag(str)
                                }
                            }/*@END_MENU_TOKEN@*/)
                        }
                    }
            .navigationTitle("Picker$Form")
        }
        
    }
}

struct OrderHidstory_Previews: PreviewProvider {
    static var previews: some View {
        OrderHidstory()
    }
}


https://www.xamrdz.com/lan/5zn1995590.html

相关文章: