I find the scale of UIPinchGestureRecognizer is confusing, so I did two experiments below, two ways to do the same thing.
gestureRecognizer.scale
start with 1.0 at the beginning of pinch (gestureRecognizer.state == .began), and gestureRecognizer.scale
in later state (.changed or .end) is always based on that, for example, if the view size is view_size
at the beginning of pinch (might not be the same with the original size orig_view_size
), gestureRecognizer.scale
always starts with 1.0, and if it becomes 2.0 later, it's size will be 2 * view_size
, so the scale always based on that when the pinch starts. And we can get the scale at the beginning of pinch (gestureRecognizer.state == .began) lastScale = self.imageView.frame.width/self.imageView.bounds.size.width
, so the scale of the original image now should be lastScale * gestureRecognizer.scale
lastScale
: The scale of last round of Pinch, a round of Pinch is from state.start to state.end, and the scale is based on the o