Open imzyf opened 5 years ago
https://stackoverflow.com/questions/34548263/button-tap-and-long-press-gesture
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(normalTap(_:))) tapGesture.numberOfTapsRequired = 1 myBtn.addGestureRecognizer(tapGesture) let longGesture = UILongPressGestureRecognizer(target: self, action: #selector(longTap(_:))) myBtn.addGestureRecognizer(longGesture) @objc func normalTap(_ sender: UIGestureRecognizer){ print("Normal tap") } @objc func longTap(_ sender: UIGestureRecognizer){ print("Long tap") if sender.state == .ended { print("UIGestureRecognizerStateEnded") //Do Whatever You want on End of Gesture } else if sender.state == .began { print("UIGestureRecognizerStateBegan.") //Do Whatever You want on Began of Gesture } }
https://stackoverflow.com/questions/34548263/button-tap-and-long-press-gesture