Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 如何使样式选择器完全可触摸_Swift_Swiftui_Swiftui Picker - Fatal编程技术网

Swift 如何使样式选择器完全可触摸

Swift 如何使样式选择器完全可触摸,swift,swiftui,swiftui-picker,Swift,Swiftui,Swiftui Picker,我用以下方式设计了选择器: Picker(selection: $selectedProduct, label: Text("Product: \(self.products[self.selectedProduct].name!)")) { ForEach(0 ..< roles.count) { Text(products[$0].name!)

我用以下方式设计了选择器:

Picker(selection: $selectedProduct, label: Text("Product: \(self.products[self.selectedProduct].name!)")) {
                
                ForEach(0 ..< roles.count) {
                    Text(products[$0].name!)
                        .frame(minWidth: 0, maxWidth: .infinity)
                }
                
            }
            .animation(nil)
            .frame(minWidth: 0, maxWidth: .infinity)
            .font(.headline)
            .foregroundColor(Color.white)
            .padding()
            .background(Color(UIColor(.blue)))
            .cornerRadius(15.0)
            .pickerStyle(MenuPickerStyle())
            
Picker(选择:$selectedProduct,标签:Text(“产品:\(self.products[self.selectedProduct].name!)){
ForEach(0..<角色数){
文本(产品[$0]。名称!)
.frame(最小宽度:0,最大宽度:无穷大)
}
}
.动画(无)
.frame(最小宽度:0,最大宽度:无穷大)
.font(.headline)
.foregroundColor(颜色.白色)
.padding()
.background(颜色(UIColor(.blue)))
.转弯半径(15.0)
.pickerStyle(MenuPickerStyle())
这将生成我想要的样式,如下所示:

不幸的是,只有标签周围的区域是可触摸的:

我想不出怎么让整个东西都可以触摸。我错过什么了吗


任何帮助都将非常感谢。

尝试将所有与大小/帧相关的修改器应用于内部标签,而不是选择器本身,如

   Picker(selection: $selectedProduct, label: 
      Text("Product: \(self.products[self.selectedProduct].name!)")
         .frame(minWidth: 0, maxWidth: .infinity)
         .font(.headline)
         .foregroundColor(Color.white)
         .padding()
         .background(Color(UIColor(.blue)))
         .cornerRadius(15.0)
   ) {
            
        ForEach(0 ..< roles.count) {
            Text(products[$0].name!)
                .frame(minWidth: 0, maxWidth: .infinity)
        }
        
    }
    .animation(nil)
    .pickerStyle(MenuPickerStyle())
Picker(选择:$selectedProduct,标签:
文本(“产品:\(self.products[self.selectedProduct].name!))
.frame(最小宽度:0,最大宽度:无穷大)
.font(.headline)
.foregroundColor(颜色.白色)
.padding()
.background(颜色(UIColor(.blue)))
.转弯半径(15.0)
) {
ForEach(0..<角色数){
文本(产品[$0]。名称!)
.frame(最小宽度:0,最大宽度:无穷大)
}
}
.动画(无)
.pickerStyle(MenuPickerStyle())