Swift UI - Wheel Picker, Change Alignment and Fontsize
Asked Answered
B

1

7

Is it possible to customise the wheel pickers font und change the alignment to .leading?

Buttery answered 9/5, 2020 at 10:54 Comment(1)
Yes, same process how you go for normal Text, for alignment you can wrap it inside HStack and + use SpacerClosehauled
M
11

I think this will be what you expect.

struct ContentView: View {
    let colors = ["Red", "Yellow", "Green", "Gray", "Black", "Purple", "White", "Brown", "Pink", "Blue"]
    @State private var color = "Red"
    var body: some View {
        Picker(selection: $color, label: Text("")) {
            ForEach(self.colors, id: \.self) { color in
                HStack {
                    Text(color)
                        .font(.title)
                        .padding()
                    Spacer()
                }
            }
        }
        .pickerStyle(WheelPickerStyle())
        .labelsHidden()
    }
}
Mencius answered 9/5, 2020 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.