ピンチジェスチャーを使用してズームインまたはズームアウトした後、元の画像サイズに戻したいとします。私はそれがscrollViewを使用して、同様の答えがUIPinchGestureRecognizerのピンチイン/アウト後の元の画像サイズを取得
How to get original image when we zoom in and zoom out the image in iosある
を発見した何
。私が必要とするものではありません。
はここに私のコードです、それはいくつかの提案を得るために#selector
func respondToGesture(_ gesture: UIGestureRecognizer) -> Void {
if let pinch = gesture as? UIPinchGestureRecognizer {
if let img = pinch.view as? UIImageView {
img.transform = CGAffineTransform(scaleX: pinch.scale, y: pinch.scale)
if pinch.state == .ended
{
img.transform = CGAffineTransform(scaleX: (1/pinch.scale), y: (1/pinch.scale))
}
}
}
}
希望により送信されたジェスチャー対応です!おかげで〜
あなたのズーム後に 'img.transform = CGAffineTransform.identity'を試してください。 –
@MikeAlter、ありがとう、それはうまくいきます。 – HungCLo
ようこそ、私は今から答えを投稿するべきだと思う:D –