Unable to center a Picker using SwiftUI

Use .labelsHidden() to hide the Picker's label.

Even if the label is hidden, I'd recommend adding a descriptive label so the label can be used by screen readers.

(credit)


You have to hide the labels in order to center the picker. You can also edit a height and clip it to have a custom picker height.

var body: some View {
  VStack {

    Picker(selection: $selection, label: Text("") {
      ForEach(0 ..< options.count) {
        Text(self.options[$0]).tag($0)
      }
    }
    .labelsHidden()
    .frame(height: 50)
    .clipped()
  }
}

Tags:

Ios

Swift

Swiftui