Created
July 30, 2017 03:18
-
-
Save Alicelovecode/9eb01de71dbecfac3b46bd0d3b30fdb7 to your computer and use it in GitHub Desktop.
UILongPressGestureRecognizer.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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