@IBOutlet weak var imageTitle: UILabel!
@IBOutlet weak var profileImage: UIImageView!
func titleStyle(){
imageTitle.layer.borderWidth = 1.0
imageTitle.layer.borderColor = UIColor.grayColor().CGColor
imageTitle.layer.cornerRadius = 10.0
// Apply Gesture to label
imageTitle.userInteractionEnabled = true
imageTitle.tag = 10
imageTitle.addGestureRecognizer(UIGestureRecognizer(target: self, action: "tappedLabel"))
}
点击标签时这段代码似乎无法正常工作。
func tappedLabel(gesture: UIGestureRecognizer){
print("Hi")
}
最佳答案
我认为您在添加操作时漏掉了“:”。
imageTitle.addGestureRecognizer(UIGestureRecognizer(target: self, action: "tappedLabel:"))
关于ios - UILabel 手势响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34196241/