【发布时间】:2021-09-29 18:02:01
【问题描述】:
更新到 iOS 15 和 Xcode 13 后,我的应用中的选择器不再显示自定义标签。在 iOS 14 设备上运行应用程序,选择器呈现良好。
这是当前实现的代码 sn-p,截图是它目前在 iOS 15 模拟器中的样子。
@State var selectedNumber: Int = 0
var body: some View {
Picker(selection: $selectedNumber, label: customLabel) {
ForEach(0..<10) {
Text("\($0)")
}
}
}
var customLabel: some View {
HStack {
Image(systemName: "paperplane")
Text(String(selectedNumber))
Spacer()
Text("⌵")
.offset(y: -4)
}
.foregroundColor(.white)
.font(.title)
.padding()
.frame(height: 32)
.background(Color.blue)
.cornerRadius(16)
}
【问题讨论】:
-
使用里面有选择器的菜单,就像我在这里的回答:stackoverflow.com/a/68897763/1601849