Skip to main content

Pulldown Menü in der Toolbar

Hier wird die Frage beantwortet, wie ich ein Pulldown Menü oben rechts in der Toolbar platzieren kann.

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationStack {
            Text("Main View")
                .toolbar {
                    ToolbarItem(placement: .topBarTrailing) {
                        Menu {
                            Button("Profile", action: {})
                            Button("Logout", role: .destructive, action: {})
                        } label: {
                            Label("Options", systemImage: "ellipsis.circle")
                        }
                    }
                }
        }
    }
}