Rotation gesture produces undesired rotation

前端 未结 2 1590
抹茶落季
抹茶落季 2021-01-22 07:15

I need to rotate an UIImageview on user\'s motion using just one finger motion. For that I use a rotation gesture and then override touchesMoved with this code:



        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-22 07:50

    The problem is that you are saying

    rotateImageView.transform = CGAffineTransformMakeRotation(angle)
    

    So whatever transform the image view has already (from the previous rotation) is thrown away and completely replaced by a new transform starting at angle. That's the "jump" you are seeing.

    What you want to do is apply a rotation transform to the existing transform of the image view. You can do that by calling CGAffineTransformRotate, instead of CGAffineTransformMakeRotation.

提交回复
热议问题