UIimageView围绕一个点旋转
我有一个图像(一条直线),并尝试从特定点以某个角度旋转它。发生的情况是图像从其自身的中心点旋转。我不想要一种使图像的底部保持不变并且以我想要的角度旋转的方式,就像时钟一样。 我使用
Compass2.layer.anchorPoint= CGPointMake(0.5,1);
[Compass2 setTransform:CGAffineTransformMakeRotation(XXXX)];
但是它显示访问属性的未知“achorPoint”组件。 谁能给我一些解决方案
I've got an image (a straight line) and am trying to rotate it in some angle from a specific point. What happens is that the image is rotated from the center point of itself. I wan't a way through which the base of the image remains the same and it rotates in the angle I want to, just as in case of a clock.
I use
Compass2.layer.anchorPoint= CGPointMake(0.5,1);
[Compass2 setTransform:CGAffineTransformMakeRotation(XXXX)];
However it shows Accessing unknown 'achorPoint' component of a property.
Can anyone give me some solutions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
CGAffineTransform 只是一个描述旋转、平移和缩放的矩阵。
请记住,您可以使用
链接变换。这基本上意味着您正在乘以变换矩阵。
所以既然你知道,标准旋转只是围绕 UIImageView 的中心旋转,你可以将你的任务分成 3 部分,
并将它们链接起来。
我没有测试这段代码,但你应该通过这种方式得到一个解决方案。
编辑:我还意识到我没有使用串联。如果使用“CGAffineTransformMake...”,则需要使用串联。我只是将这些功能相互放入。
Well a CGAffineTransform is just a Matrix describing rotation, translation and scaling.
Remember you can use
to chain up transforms. This basically just means you are multiplying the transformation matrizes.
So since you know, the standard Rotation just rotates around the center of the UIImageView, you could break up your task into 3 parts,
and chain them up.
I didn't test this code, but you should get a solution along this way.
EDIT: I also realized I didn't use the Concatenation. You need to use the concatenation if you use "CGAffineTransformMake...". I just put the functions into each other.
我也有同样的问题。正如“aBitObvious”所指出的,您必须导入QuartzCore框架才能访问CALayer类的anchorPoint属性。
I had this same problem. As "aBitObvious" pointed out, you must import the QuartzCore framework to access the anchorPoint property of the CALayer class.
它给您的错误意味着您正在尝试设置一个不存在的属性。您是否拼错了“anchorPoint”?如果情况并非如此,并且您的问题只是有一个拼写错误,请仔细检查您的类型。您的“Compass2”应该是某种 UIView,其“图层”应该是 CALayer 对象。
The error it is giving you implies you are trying to set a property that doesn't exist. Did you misspell 'anchorPoint'? If that isn't the case and your question merely has a typo, double check your types. Your 'Compass2' should be a UIView of some sort and its 'layer' should be a CALayer object.
您可能无法仅通过导入
ie 来访问视图的属性anchorPoint;
为此,您必须在实现文件的开头编写以下导入语句。
现在您将能够编写以下代码而不会产生任何错误。
You may not be able to access the property anchorPoint for your view by just importing
ie;
For that you have to write the following import statement in the beginning of the implementation file.
Now you will be able to write the following code without generating any errors.