//缩小放大图片
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 }