The next pattern code exhibits my downside:
import SwiftUI
struct TestView: View
{
enum Possibility: Int, CaseIterable, Hashable, Identifiable {
var id: Self { self }
case one = 1
case two = 2
case three = 3
var title: String {
swap self {
case .one: return "One"
case .two: return "Two"
case .three: return "Three"
}
}
var picture: some View {
Picture("TestImage")
.body(width: 24.0, top: 24.0)
.clipShape(.circle)
.overlay {
Circle()
.strokeBorder(.black)
}
}
}
@State var selectedOptions: Set<Possibility> = []
var physique: some View {
VStack {
VStack {
ForEach(Possibility.allCases) { choice in
Label {
Textual content(choice.title)
} icon: {
choice.picture
}
}
}
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
Menu {
ForEach(Possibility.allCases) { choice in
let binding = Binding<Bool> {
selectedOptions.incorporates(choice)
} set: { worth in
if worth {
selectedOptions.insert(choice)
} else {
selectedOptions.take away(choice)
}
}
Toggle(isOn: binding) {
Label {
Textual content(choice.title)
} icon: {
choice.picture
}
}
}
} label: {
Picture(systemName: "guidelines")
}
.menuOrder(.fastened)
}
}
}
}
#Preview {
TestView()
}
The picture present within the menu differs from what I might anticipate and what’s proven within the VStack
Does anybody know why that is taking place, and the way I could make the icons within the menu seem the identical approach they do in VStack?


