import SwiftUI
struct MenuExample : View {
@State var color : Color = .white
var body: some View {
NavigationView {
ZStack {
color.opacity(0.3).ignoresSafeArea()
VStack {
Text("Content")
.font(.system(size: 64))
.foregroundColor(color)
}
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Menu {
Button {
color = .red
} label: {
Text("Red")
}
Button {
color = .green
} label: {
Text("Green")
}
Button {
color = .blue
} label: {
Text("Blue")
}
} label: {
Text("+")
.padding()
.background(.gray.opacity(0.2))
}
}
}
.navigationTitle("Colors")
}
}
}
import SwiftUI
struct MenuExample : View {
@State var color : Color = .white
var body: some View {
NavigationView {
ZStack {
color.opacity(0.3).ignoresSafeArea()
VStack {
Text("Content")
.font(.system(size: 64))
.foregroundColor(color)
}
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Menu {
Button {
color = .red
} label: {
Text("Red")
}
Button {
color = .green
} label: {
Text("Green")
}
Button {
color = .blue
} label: {
Text("Blue")
}
Menu {
Button {
} label: {
Label("Share", systemImage: "square.and.arrow.up")
}
Button {
} label: {
Label("Print", systemImage: "printer")
}
} label: {
Label("More", systemImage: "ellipsis")
}
} label: {
Text("+")
.padding()
.background(.gray.opacity(0.2))
}
}
}
.navigationTitle("Colors")
}
}
}