美文网首页
轻点手势

轻点手势

作者: 焉逢12 | 来源:发表于2017-03-04 15:02 被阅读0次
    import UIKit
    
    class ViewController: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
            // Do any additional setup after loading the view, typically from a nib.
            let img = UIImageView(frame: CGRect(x: 50, y: 100, width: 100, height: 80))
            img.image = UIImage(named: "180-0")
            //设置允许交互
            img.isUserInteractionEnabled = true
            let tap1 = UITapGestureRecognizer(target: self, action: #selector(tapClick))
            img.addGestureRecognizer(tap1)
            
            
            self.view.addSubview(img)
            
            
        }
        func tapClick()
        {
            print("点击了图片")
        }
    
        override func didReceiveMemoryWarning() {
            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.
        }
    
    
    }
    

    相关文章

      网友评论

          本文标题:轻点手势

          本文链接:https://www.haomeiwen.com/subject/dbqjgttx.html