IOS UIPinchGestureRecognizer 捏合手势

//缩小放大图片
 1 override func viewDidLoad() {
 2 super.viewDidLoad()
 3 // Do any additional setup after loading the view,
 typically from a nib.
 4 let rect = CGRect(x:0, y:80, width:320, height:
 
 5 let imageView = UIImageView(frame:rect)
 6
 7 let image = UIImage(named:“Hand”)
 8 imageView.image = image
 9
 10 imageView.isUserInteractionEnabled = true
 11 self.view.addSubview(imageView)
 12
 13 let guesture = UIPinchGestureRecognizer(target:self,
 action:#selector(ViewController.pinchImage(:)))
 14 imageView.addGestureRecognizer(guesture)}
 15 func pinchImage( recognizer:
 UIPinchGestureRecognizer)
 16 {
 17 recognizer.view?.transform =
 (recognizer.view?.transform.scaledBy(x:recognizer.scale,
 y: recognizer.scale))!
 18 recognizer.scale = 1;
 19 }

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券