UIPinchGestureRecognizer在Collection View单元中的UIImageView上不起作用

时间:2019-04-24 16:19:47

标签: xcode10 uipinchgesturerecognizer swift5

我在collectionViewCell的imageView上添加了别针手势。但这行不通。这是我的代码。

  cell.imageView.isUserInteractionEnabled = true
        let pinGesture = UIPinchGestureRecognizer(target: self, action: #selector(pinGesture(sender:)))
        cell.imageView.addGestureRecognizer(pinGesture)

    @objc func pinGesture(sender: UIPinchGestureRecognizer) {
        sender.view?.transform = (sender.view?.transform.scaledBy(x: sender.scale, y: sender.scale))!
        sender.scale = 1.0
    }

0 个答案:

没有答案