Reset view after UIRotationGesture

2019-05-20 09:26发布

问题:

I have a UIRotationRecognizer on an UIImageView. After I rotate the view I would like to commit the changes so that next time I rotate the image it rotates naturally. Currently, with the code below, it looks like the origin is off after release the touch and try to rotate again.

    [Export("RotationSelector")]
    private void RotationSelector(UIRotationGestureRecognizer recognizer)
    {
        recognizer.View.Transform = CGAffineTransform.MakeRotation(recognizer.Rotation);

        if (recognizer.State == UIGestureRecognizerState.Ended)
            // Reset origin here... 

    }

Thanks

回答1:

You need to reset your transformation like this:

recognizer.View.Transform = CGAffineTransform.MakeIdentity();