Home > Mobile >  Do the Binding SwiftUI: how to use the Dictionary?
Do the Binding SwiftUI: how to use the Dictionary?

Time:09-18

I'm going to do a line buttong, then each button is selected and not selected, like defines tags, according to the filter tags do,

Struct TagButton: View {
Var body: some View {
The Button (action: {
Self. Selected. Toggle ()
{})
If selected {
The Text (name)
Underline ()
} else {
The Text (name)
}
}
The padding ()
}
@ Binding var selected: Bool
Let the name: String
}

Struct TagsView: View {
@ Binding var tags: [String: Bool]

Var body: some View {
ScrollView. (horizontal) {
HStack {
ForEach (tags. The keys. The sorted (), id: \. Self) {k in
TagButton (selected: self $tags [k], name: k)//[k] error Missing argument label 'dynamicMember:' in subscript
}
}
}
}

}
  • Related