Last updated 3 months ago
Was this helpful?
SwiftUI โฉ control โฉ pickers โฉ Picker
โญ๏ธ ๆณจๆ๏ผ PickerStyle.automatic ๅๅณ็ๆฏ DefaultPickerStyle๏ผๅ ฉ่ ๅ็จฑไธไธ่ด๏ผ่ซๅฐๅฟโ๏ธ
PickerStyle
.automatic
๐ SwiftUI Tutorials โฉ Working with UI Controls โฉ Sec 3. Define the Profile Editor
VStack(alignment: .leading, spacing: 20) { Text("Seasonal Photo").bold() /// โญ๏ธ Picker Picker("Seasonal Photo", selection: $profile.seasonalPhoto) { ForEach(Profile.Season.allCases) { season in Text(season.rawValue).tag(season) } } .pickerStyle(.segmented) }
๐Implicit Alignment
@State private var selection: String = "leading" let keys = ["leading", "center", "trailing"] let alignments: [String:HorizontalAlignment] = [ "leading": .leading, "center": .center, "trailing": .trailing ] /// segmented control var picker: some View { Picker("Align", selection: $selection) { ForEach(0..<3){ Text(keys[$0]).tag(keys[$0]) } } .pickerStyle(.segmented).shadow(radius: 2) .padding() // โญ๏ธ animate the change when `selection` changes .onChange(of: selection) { newSelection in withAnimation(.easeOut(duration: 1)) { self.alignment = alignments[newSelection]! } } }
SwiftUI โฉ
Picker โฉ
picker styles
PickerStyle (protocol)
View โฉ
.pickerStyle(_:)
AppCoda โฉ ๆงๅปบไธๅ่ผช็ค้ธๆๅจ (Wheel Picker)
events
Implicit Alignment