我有一张图片,当用户双击该图片时,我会显示一个带有勾号的按钮,就像用户已经勾选了该图片。我在Storyboard中首先将按钮设置为隐藏。
我使用以下代码来检测单元格的点击:
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if collectionView == self.subOptionsCollectionView{
let imageNamed = "\(customizeOptionSelected[indexPath.row])"
shirtImage.image = UIImage(named: imageNamed)
let tap = UITapGestureRecognizer(target: self, action: #selector(doubleTapped))
tap.numberOfTapsRequired = 2
collectionView.addGestureRecognizer(tap)
}
}
func doubleTapped() {
print("Double Tap")
}
但是如何显示那个勾选框/按钮?