1

I am trying to create a image swift class/file and then add it to the view in another class...it has gestures attached to it programmatically using addTarget

class GestureCreate: UIImageView,UIGestureRecognizerDelegate {

init(){
    let imageName = "hairoverlay"
    let image = UIImage(named: imageName)

    super.init(image: image)


    self.overlayImage = UIImageView(image: image!)

    self.overlayImage.frame = CGRect(x: 0, y: 0, width: 100, height: 200)
    self.overlayImage.isUserInteractionEnabled = true
    self.overlayImage.isMultipleTouchEnabled = true
    // view.addSubview(overlayImage)



    self.pinchGesture.delegate = self





    self.pinchGesture.addTarget(self, action: #selector(GestureCreate.pinchAction(_:)))


    self.overlayImage.addGestureRecognizer(self.pinchGesture)

}

and then in the view controller I have

        var test = GestureCreate()
       self.view.addSubview(test.overlayImage)

Its funny because the image appears on the view but the actions I tryed adding to it doesnt work... anyone know whats up?

0 Answers0