tap gesture recognizer - which object was tapped?

前端 未结 12 1327
萌比男神i
萌比男神i 2020-12-29 17:47

I\'m new to gesture recognizers so maybe this question sounds silly: I\'m assigning tap gesture recognizers to a bunch of UIViews. In the method is it possible to find out w

12条回答
  •  梦谈多话
    2020-12-29 18:17

    Use this code in Swift

    func tappGeastureAction(sender: AnyObject) {
        if let tap = sender as? UITapGestureRecognizer {
            let point = tap.locationInView(locatedView)
            if filterView.pointInside(point, withEvent: nil) == true {
                // write your stuff here                
            }
        }
    }
    

提交回复
热议问题