1

如何将视图的旋转重置为零,同时保持该视图上的其他转换不变。

我不能使用:

[myView setTransform:CGAffineTransformIdentity]

因为它也将休息所有其他变换。

或者我只想要视图的框架,如果它的旋转为 0。

4

2 回答 2

0
myView.transform = CGAffineTransformRotate(myView.transform, -currentRotationAngle);

this will take the current transform, and rotate it to 0 degrees

Edit: i think you will need to rotate by the inverse of your current rotation value, not just set it to 0

于 2012-10-17T12:40:54.973 回答
0

要在保持过渡的同时重置旋转,您可以尝试以下代码:

  CGAffineTransform inverse = CGAffineTransformInvert(myView.affineTransform);
  inverse.tx = 0;
  inverse.ty = 0;
  myView.transform = inverse;
于 2013-05-22T12:52:55.537 回答