UIImageView Gestures (Zoom, Rotate) Question

后端 未结 5 1829
陌清茗
陌清茗 2020-11-30 18:28

I would like to make 2 operations to an UIImageView zoom, rotate, I have 2 problems:

A. I make an operation for zoom for ex

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 18:42

    When you use CGAffineTransformMakeScale, you are resetting the transformation of Identity every time you use it and you lose the previous transformation information.

    Try using CGAffineTransformScale(view.transform,scale, scale) for the pinch zooming. You will need to retain the original frame size to keep the zooming under control though.
    see: How can I use pinch zoom(UIPinchGestureRecognizer) to change width of a UITextView?

    For rotation similarly:

       if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
            view.transform = CGAffineTransformRotate([view transform], [gestureRecognizer rotation]);
            [gestureRecognizer setRotation:0];
        }
    

提交回复
热议问题