我想使用 SwiftUI 的新
Menu
,但不幸的是,我无法解决一个问题。在选择 Menu
的一个值后,菜单标题看起来像这样:
然而,我不希望标题降低其不透明度。我该如何实现这个目标?
以下是我的代码:
struct ContentView: View {
@State private var selectionVariable = 0
let sampleDict = [0: "Sample Title 1", 1: "Sample Title 2"]
var body: some View {
Menu {
Picker(selection: $selectionVariable, label: Text("")) {
ForEach(sampleDict.sorted(by: <), id: \.key) { base, name in
Text(name)
}
}
}
label: {
Text("Eingaben im \(sampleDict[selectionVariable] ?? "")")
}
}
}
.id()
,这个错误仍然存在。 - Joannes