xcode IOS:旋转 uiimageview
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11230625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IOS: rotate an uiimageview
提问by cyclingIsBetter
in my app I have an imageview, its name is arrow and I rotate it of 180 degrees in this way:
在我的应用程序中,我有一个图像视图,它的名称是箭头,我以这种方式将它旋转 180 度:
arrow.transform = CGAffineTransformMakeRotation(M_PI);
it work fine, but now I want that this imageview return in the original position; what's the value taht I should set to obtain it?
它工作正常,但现在我希望这个图像视图返回到原始位置;我应该设置以获得它的价值是多少?
回答by pasawaya
To make it return to it's original position, just do this:
要使其恢复到原来的位置,只需执行以下操作:
arrow.transform = CGAffineTransformMakeRotation(0);
In degrees, 0 radians is 0 degrees, so it should return to its original position.
以度为单位,0 弧度就是 0 度,所以它应该回到原来的位置。
回答by Bill Wilson
Try setting the transform
property back to the identity matrix. i.e. CGAffineTransformIdentity
尝试将该transform
属性设置回单位矩阵。IECGAffineTransformIdentity
回答by Darius Miliauskas
Swift3:
斯威夫特3:
arrow.transform = CGAffineTransform(rotationAngle: rotation);
where rotationis the angle to rotate in radians.
其中,rotation是以弧度为单位旋转的角度。