Swift UI - 滚轮选择器、更改对齐方式和字体大小
Swift UI - Wheel Picker, Change Alignment and Fontsize
是否可以自定义滚轮选择器字体并将对齐方式更改为 .leading
?
我想这将是您所期望的。
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()
}
}
是否可以自定义滚轮选择器字体并将对齐方式更改为 .leading
?
我想这将是您所期望的。
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()
}
}