慕斯王
Swift 3.0版本,双击可放大两次。@IBOutlet weak var scrollView: UIScrollView!@IBOutlet weak var imageView: UIImageView!某个地方(通常在viewDidLoad中):let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(onDoubleTap(gestureRecognizer:)))tapRecognizer.numberOfTapsRequired = 2scrollView.addGestureRecognizer(tapRecognizer)处理程序:func onDoubleTap(gestureRecognizer: UITapGestureRecognizer) { let scale = min(scrollView.zoomScale * 2, scrollView.maximumZoomScale) if scale != scrollView.zoomScale { let point = gestureRecognizer.location(in: imageView) let scrollSize = scrollView.frame.size let size = CGSize(width: scrollSize.width / scale, height: scrollSize.height / scale) let origin = CGPoint(x: point.x - size.width / 2, y: point.y - size.height / 2) scrollView.zoom(to:CGRect(origin: origin, size: size), animated: true) print(CGRect(origin: origin, size: size)) }}