我下面有一个函子,但无法发送href函子。
func someFunc() {
linkBtn.addTarget(self, action: #selector(headerClick(_:href:)), for: .touchUpInside)
return headerView
}
@objc func headerClick(_ sender: AnyObject, href: String) {
print(href)
}
答案 0 :(得分:0)
自定义按钮:
class LinkButton: UIButton {
var href: String?
}
在您的功能中
func someFunc() {
linkBtn.href = yourHref
linkBtn.addTarget(self, action: #selector(handleClink(_:)), for: .touchUpInside)
}
@objc func handleClick(_ sender: LinkButton) {
if let href = sender.href{
print(href)
}
}