Swift & SwiftUI
  • İçerikler
  • UI Bileşenleri
    • Text
    • Button
    • Image
    • Picker
    • SecureField
    • Stepper
    • Slider
    • TabView
    • Sheet
    • Action Sheet
    • Alert
  • Layout
    • Fill-Space-Equally
  • State & Data Flow
    • Content
    • EnvironmentObject
    • ObservableObject
    • ObservedObject
    • Binding
  • Gestures
    • TapGesture
    • DragGesture
    • MagnificationGesture
    • RotationGesture
    • LongPressGesture
    • Notes
  • Extra
    • GeometryReader
    • Timer
    • AlignmentGuide
    • PreferenceKey
  • Concurrency
    • Perform asynchronous operation
Powered by GitBook
On this page

Was this helpful?

  1. UI Bileşenleri

Picker

Belirli tercihler arasından seçim yapmaya yarar.

SwiftUI'ın şimdiki sürümünde SegmentedPickerStyleharicindeki stiller problemli gözüküyor. DefaultPickerStyle sadece Form içinde bulunurken çalışıyor. (Formun da NavigationView içinde olması gerekiyor.)

@State var options = (1...4).map { "Option - \($0)" }
@State var selectedOption: String = "Option - 1"

NavigationView {
    Form {
        
        Picker(selection: $selectedOption, label: Text("Select an option")) {
            ForEach(self.options, id: \.self) {
                Text($0)
            }
        }.pickerStyle(SegmentedPickerStyle())
        
        Picker(selection: $selectedOption, label: Text("Select an option")) {
            ForEach(self.options, id: \.self) {
                Text($0)
            }
        }.pickerStyle(WheelPickerStyle())
        
        Picker(selection: $selectedOption, label: Text("Select an option")) {
            ForEach(self.options, id: \.self) {
                Text($0)
            }
        }.pickerStyle(DefaultPickerStyle())
    
    }.padding()
}
PreviousImageNextSecureField

Last updated 5 years ago

Was this helpful?