Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Alicelovecode/9eb01de71dbecfac3b46bd0d3b30fdb7 to your computer and use it in GitHub Desktop.

Select an option

Save Alicelovecode/9eb01de71dbecfac3b46bd0d3b30fdb7 to your computer and use it in GitHub Desktop.
UILongPressGestureRecognizer.swift
override func viewDidLoad() {
super.viewDidLoad()
buttonArray = [button1,button2,button3,button4,button5]
if buttonArray != nil{
for button in buttonArray!{
let lpgr = UILongPressGestureRecognizer(target: self, action: #selector(ViewController.longPress(sender:)))
lpgr.minimumPressDuration = 1.5
button.addGestureRecognizer(lpgr)
}
}
}
func longPress(sender: UILongPressGestureRecognizer){
if sender.state == .began{
print("Hello")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment