我正在尝试创建一个图像swift类/文件,然后将其添加到另一个类的视图中...它使用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)
}
然后在视图控制器中我有
var test = GestureCreate()
self.view.addSubview(test.overlayImage)
它很有趣,因为图像出现在视图上,但我尝试添加到它的动作不起作用......任何人都知道它是什么?