Picker

作者: 水之飞亦 | 来源:发表于2020-03-30 15:25 被阅读0次

Creating a Picker

init(LocalizedStringKey, selection: Binding<SelectionValue>, content: () -> Content)

Available when Label is Text.

init<S>(S, selection: Binding<SelectionValue>, content: () -> Content)

Available when Label is Text.

init(selection: Binding<SelectionValue>, label: Label, content: () -> Content)

Creates an instance that selects from content associated with Selection values.

Styling Pickers

struct DefaultPickerStyle
struct PopUpButtonPickerStyle
struct RadioGroupPickerStyle
struct SegmentedPickerStyle
struct WheelPickerStyle

protocol PickerStyle

A custom specification for the appearance and interaction of a Picker.

var section = ["1","2","3","4","5","6"]
@State var selectRow = 1
var body: some View {
    
    VStack {
        
        Picker.init("Picker", selection: $selectRow) {
            ForEach(0..<self.section.count) { i in
                Text(self.section[i])
            }
        }
        
        .pickerStyle(SegmentedPickerStyle())
        
        Picker.init(selection: $selectRow, label: Text("Picker")) {
            ForEach(0..<self.section.count) { i in
                Text(self.section[i])
            }
        }
        .pickerStyle(WheelPickerStyle())
        .foregroundColor(Color.purple)
        .background(Color.init(red: 0.9, green: 0.9, blue: 0.9))
        .font(Font.system(size: 20))
        
        
    }.padding(EdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20))
    
}

相关文章

网友评论

      本文标题:Picker

      本文链接:https://www.haomeiwen.com/subject/crfeuhtx.html