Can I set the origin of rotation when rotating an view with CGAffineTransformMakeRotation()?

不羁岁月 提交于 2019-12-13 09:25:01

问题


I have an UIImageView which I want to rotate a little bit, but I need to define an special origin for rotation. How could I do that? More precisely, I have an image of a goblet, and I want it to wiggle on a table. It's socket is quadrate. So when wiggeling to left, then my rotation origin has to be the left corner of that quadrate. And when wiggeling to right, the rotation origin has to be the right corner of that quadrate.

How could I do that? I already have this:

myView.transform = CGAffineTransformMakeRotation(.25);


回答1:


There was a similar question on how to achieve this here.

The best answer was to change the anchorPoint property of the underlying layer of the UIView.



来源:https://stackoverflow.com/questions/854137/can-i-set-the-origin-of-rotation-when-rotating-an-view-with-cgaffinetransformmak

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!