【发布时间】:2020-09-03 06:54:19
【问题描述】:
在 SwiftUI 中,我创建了一个按钮循环。
点击按钮时我必须获取标签值。
我试过很多次了。我无法获取点击了哪个按钮
HStack(spacing: 1) {
ForEach(0...2, id: \.self) { j in
Button(action: {
// need button Tag
print("Tapped Button Tag:")
}, label: {
Text("")
})
.tag("\(j)")
}
}
【问题讨论】:
标签: ios swift xcode button swiftui