我有以下视图:
相应的Swift代码如下:
struct TestView: View {
let options = [" ", "1", "2", "3", "4", "5", "6"]
@State var selectedIndex: Int = 0
var body: some View {
HStack(spacing: 0) {
Text("One")
Spacer()
Picker(selection: $selectedIndex, label: Text(options[selectedIndex])) {
ForEach(0 ..< options.count) {
Text(options[$0])
}
}
.background(Color.red)
.pickerStyle(MenuPickerStyle())
}
.padding(EdgeInsets(top: 0, leading: 16, bottom: 0, trailing: 16))
.background(Color.yellow)
}
}
点击红色正方形后,将会打开Picker:
如何扩大红色矩形的触摸区域,使其包括整个黄色区域?