使用CGAffineTransformMakeRotation()旋转视图时,可以设置旋转原点吗? [英] Can I set the origin of rotation when rotating an view with CGAffineTransformMakeRotation()?

查看:191
本文介绍了使用CGAffineTransformMakeRotation()旋转视图时,可以设置旋转原点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个要旋转一点的UIImageView,但是我需要定义一个特殊的旋转原点。我该怎么办?更准确地说,我有一个高脚杯的图像,我希望它在桌子上摆动。它的插槽是方形的。因此,当向左摆动时,我的旋转原点必须是该正方形的左角。而且当向右摆动时,旋转原点必须位于该正方形的右角。

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);

myView.transform = CGAffineTransformMakeRotation(.25);

推荐答案

关于如何实现此

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

最好的答案是更改 anchorPoint UIView 的基础层的code>属性。

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

这篇关于使用CGAffineTransformMakeRotation()旋转视图时,可以设置旋转原点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆