ios - 分段选择器内的元素修饰符不起作用

标签 ios swift swiftui

我有一个代码:

@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 的元素内的修饰符.但实际上我看不到任何效果:

enter image description here

为什么修饰符不起作用?

最佳答案

这是你的pickerStyle() .文档说关于 SegmentedPickerStyle :

  • Note: Only supports segments of type Label and Image. Passing any other type of view will result in a visible, but empty, segment.


我想这就是为什么你只看到文字。我尝试过使用另一种风格,效果很好。

关于ios - 分段选择器内的元素修饰符不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58864088/

相关文章:

ios - 是否可以在单独的文件中包含UISearchBarDelegate扩展名?

ios - 如何使用 .monospaced 系统字体设计

swift - 如何在 Swift 5.5 中等待来自同步函数的异步函数?

ios - 如何在 NSPredicate 中定义临时变量?

ios - 如何在脱机同步中处理核心数据关系-Azure移动服务iOS

ios - 如何在 iOS 中使用 for 循环以编程方式添加 UIButton?

ios - 我正在使用 NavigationLink 在 View 之间导航,但它在 SwiftUI 中的单个 View 中不起作用

swift - 如何将 Swift UI View 转换为 NSImage

iOS CollectionView 帮助(保存当前状态)

ios - 如何将乘数应用于在 nib 文件上创建的所有约束?