菜单标题问题和不透明度降低

Issue with Menu title and decreased opacity

我想将新的 Menu 与 SwiftUI 一起使用,但很遗憾,有一个问题我无法解决。选择 Menu 的一个值后,Menutitle 如下所示:

但是我不希望标题降低其不透明度。我怎样才能做到这一点?

这是我的代码:

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] ?? "")")
        }
    }
}

它看起来像一个错误。

一种可能的解决方法是使用 .animation(nil):

删除 Picker 动画
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] ?? "")")
        }
        .animation(nil) // add here
    }
}

我会说它看起来像一个错误,无论如何值得向 Apple 提交反馈。

这是经过测试的解决方法 (Xcode 12.1 / iOS 14.1)

    label: {
        Text("Eingaben im \(sampleDict[selectionVariable] ?? "")")
                .id(selectionVariable)    // << this one !!
    }