【发布时间】:2017-03-16 12:46:17
【问题描述】:
我在一个视图中放置了三个按钮,每个按钮都有不同的个人资料图片。当触摸开始对任何单个按钮进行触摸时,我需要所有三个按钮都突出显示,以便三个按钮一起看起来是一个按钮。我已经尝试了以下代码,但它不起作用。有什么想法吗?
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(normalTap))
tapGesture.numberOfTapsRequired = 1
friendsBtn1.addGestureRecognizer(tapGesture)
func normalTap(sender: UITapGestureRecognizer){
if sender.state == .began {
friendsBtn2.isHighlighted = true
friendsBtn3.isHighlighted = true
}
if sender.state == .ended {
friendsBtn2.isHighlighted = false
friendsBtn3.isHighlighted = false
}
print("Normal tap")
}
【问题讨论】:
-
你为friendsBtn2和friendsBtn3设置了高亮图像吗?
-
结帐更新的答案。
标签: ios swift3 uibutton touchesbegan