0

I want to display a picker with several options to choose one of them. I could do it but the problem is that the menu shows collapsed.

How can I show the menu display uncollapsed?

enter image description here

Example Code:

struct TestingView: View {

enum Options: String, CaseIterable {
    case option1
    case option2
    case option3
}

@State var selectedOrder: Options = .option1

var body: some View {
    NavigationStack{
        VStack {
            Text("Custom Text")
        }
        .toolbar {
            ToolbarItem(placement: .navigationBarTrailing) {
                Menu {
                    Picker("Order by", selection: $selectedOrder) {
                        ForEach(Options.allCases, id: \.self) {
                            Text($0.rawValue)
                        }
                    }
                    .pickerStyle(.menu)
                } label: {
                    Image(systemName: "arrow.up.arrow.down")
                }
            }
        }
    }
}}
Ariel Antonio Fundora
  • 1,330
  • 15
  • 20

0 Answers0