How do you make an UIImageView on the storyboard clickable (swift)

前端 未结 7 639
后悔当初
后悔当初 2020-12-13 02:39

I am new to swift (and Xcode development in general) and I was wondering how to make an ImageView on the storyboard clickable. What I\'m trying to do is make it so when its

相关标签:
7条回答
  • 2020-12-13 03:09

    for swift version 3.0 try below code

    override func viewDidLoad() {
    super.viewDidLoad()
    
    let tap1 = UITapGestureRecognizer(target: self, action: #selector(tapGesture1))
    imageview.addGestureRecognizer(tap1)
    imageview.isUserInteractionEnabled = true
    }
    func tapGesture1() {
        print("Image Tapped")
    }
    
    0 讨论(0)
提交回复
热议问题