【发布时间】:2021-06-04 06:02:52
【问题描述】:
在 UIKit 中,我通过代码捕获按钮发送者(点击了哪个按钮)
let colorVC = UIColorPickerViewController()
colorVC.delegate = self
clickedButton = sender
present(colorVC, animated: true)
}
我想在 SwiftUI 中完成同样的事情。
flagList.name 来自 struct,我想知道点击了哪个按钮,以便相应地调整 Flag 名称。
``` Button(action: {
print("tapped")
}, label: {
List(flagList) { flagList in
HStack(spacing: 15){
Image(flagList.flagName)
.resizable()
.scaledToFit()
.clipShape(Circle())
.frame(width: 30, height: 30, alignment: .trailing)
Text(flagList.name)
.font(.system(size: 25, weight: .light, design: .default))
}
}
【问题讨论】:
标签: ios swift uikit swiftui-form