我有一个代码:
@Binding var hand: Hand
var body: some View {
HStack {
Text("Hand: ")
Picker(selection: $hand, label: Text("Strength")) {
Text("JIUJIU").tag(0).foregroundColor(.blue)
Text("BLABLA").tag(1).rotationEffect(Angle(degrees: 35))
}.pickerStyle(SegmentedPickerStyle())
}
}
有
foregroundColor(.blue)
和 rotationEffect(Angle(degrees: 35))
Picker
的元素内的修饰符.但实际上我看不到任何效果:为什么修饰符不起作用?
最佳答案
这是你的pickerStyle()
.文档说关于 SegmentedPickerStyle
:
- Note: Only supports segments of type
Label
andImage
. Passing any other type of view will result in a visible, but empty, segment.
我想这就是为什么你只看到文字。我尝试过使用另一种风格,效果很好。
关于ios - 分段选择器内的元素修饰符不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58864088/