タイトルバーにメニューボタンを設置してみた。メニューにButtonを設置することは出来るが、Text, Pickerの設置してもコンパイルエラーは発生しないがPreview Canvasに表示されない。もちろん、Debug実行しても表示されない。(俺的メモ: ToolbarContent@FloatingTabBarワークスペース)
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
print("Cancel")
}
}
ToolbarItem(placement: .primaryAction) {
Menu("Menu") {
Button(action: {
print("Heart") }) { Text("Heart")
Image(systemName: "heart.circle.fill")
.symbolRenderingMode(.palette)
// .symbolRenderingMode(.multicolor)
.foregroundStyle(.red, .yellow)
}
}
Text("OK")
List {
Picker("Flavor", selection: $selectedFlavor) {
Text("Chocolate").tag(Flavor.chocolate)
Text("Vanilla").tag(Flavor.vanilla)
Text("Strawberry").tag(Flavor.strawberry)
}
}
}
} // toolbar