PinchGesture не работает в Xcode11 в Swift 5
Я пытаюсь выполнить PinchGesture в Xcode 11.2, но не работает, дайте правильный ответ. Там есть код.
override func viewDidLoad() {
super.viewDidLoad()
imageView.frame = CGRect(x: 100, y: 200, width: 300, height: 300)
imageView.image = #imageLiteral(resourceName: "Movies")
imageView.isUserInteractionEnabled = true
self.view.addSubview(imageView)
imageView.center = view.center
pinchGesture.scale = 1
pinchGesture.isEnabled = true
imageView.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true
imageView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
imageView.addGestureRecognizer(pinchGesture)
pinchGesture.addTarget(self, action: #selector(pinchedView))
}
@objc func pinchedView(){
guard let gestureview = pinchGesture.view else {
return
}
gestureview.transform = gestureview.transform.scaledBy(x: pinchGesture.scale, y: pinchGesture.scale)
}