thieumao

Tap Image by code Swift 3

Dec 17th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.61 KB | None | 0 0
  1. //
  2. //  ViewController.swift
  3. //  Learn Gesture
  4. //
  5. //  Created by Thieu Mao on 12/17/16.
  6. //  Copyright © 2016 thieumao. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ViewController: UIViewController {
  12.  
  13.     @IBOutlet weak var myImage: UIImageView!
  14.    
  15.     override func viewDidLoad() {
  16.         super.viewDidLoad()
  17.         let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleTap))
  18.         tap.numberOfTapsRequired = 1
  19.         tap.numberOfTouchesRequired = 1
  20.         self.myImage.addGestureRecognizer(tap)
  21.     }
  22.    
  23.     func handleTap() {
  24.         print("Touched")
  25.     }
  26.    
  27. }
Advertisement
Add Comment
Please, Sign In to add comment