Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with Menu title and decreased opacity

I want to use the new Menu with SwiftUI but unfortunately there is one issue which I can't solve. After selecting one value of the Menu the Menutitle looks like so:

enter image description here

However I don't want the title to decrease it's opacity. How can I achieve this?

Here is my code:

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] ?? "")")
        }
    }
}
like image 267
finebel Avatar asked Sep 01 '25 04:09

finebel


1 Answers

I'd say it looks like a bug, anyway worth submitting feedback to Apple.

Here is tested workaround (Xcode 12.1 / iOS 14.1)

    label: {
        Text("Eingaben im \(sampleDict[selectionVariable] ?? "")")
                .id(selectionVariable)    // << this one !!
    }
like image 80
Asperi Avatar answered Sep 02 '25 17:09

Asperi