1 override func viewDidLoad() {
2 super.viewDidLoad()
3 // Do any additional setup after loading the view,
typically from a nib.
4 let rect = CGRect(x:0, y:80, width:320, height:
5 self.imageView = UIImageView(frame:rect)
6
7 let image = UIImage(named:“lock”)
8 imageView.image = image
9
10 imageView.isUserInteractionEnabled = true
11 self.view.addSubview(self.imageView)
12
13 let guesture = UITapGestureRecognizer(target:self,
action:#selector(ViewController.doubleTap))
14 guesture.numberOfTapsRequired = 2
15 guesture.numberOfTouchesRequired = 1
16 imageView.addGestureRecognizer(guesture)
17 }
//numberOfTapsRequired 点击两次
//numberOfTouchesRequired 1根手指