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

前端 未结 7 654
后悔当初
后悔当初 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条回答
  •  -上瘾入骨i
    2020-12-13 02:57

    I achieved this by setting user interaction enable = true

    and this code below in TouchesBegan... Clean and simple for this

    ImageView was also inside a StackView

    if let touch = touches.first {
       if touch.view == profilePicture {
          print("image touched")
       }
    }
    

提交回复
热议问题