Objective-C CALayer UIView 真实旋转

发布于 2024-12-18 05:00:04 字数 493 浏览 3 评论 0原文

我正在尝试旋转 UIView 对象,如下图所示 http://i.piccy.info/i7/f8ff7fe488c7c492e6ff6a689bc9cdeb/1-5-2127/60800682/rotation.png

我正在尝试使用 CALayer 的转换,但我得到这样的结果: http://i.piccy.info/i7/bbb672b058fdfdd251cc90f1ce2b9c1f/1-5-2128/9488743/rotate2.png

I'm trying to rotate a UIView object like shown on the image below
http://i.piccy.info/i7/f8ff7fe488c7c492e6ff6a689bc9cdeb/1-5-2127/60800682/rotation.png

I'm trying to use the CALayer's transform but I get something like this:
http://i.piccy.info/i7/bbb672b058fdfdd251cc90f1ce2b9c1f/1-5-2128/9488743/rotate2.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小鸟爱天空丶 2024-12-25 05:00:04

如果我理解正确,您想要向后标题视图(进入屏幕),应该能够实现如下所示的效果:

float distance = 50;

CATransform3D basicTrans = CATransform3DIdentity;
basicTrans.m34 = 1.0 / -distance;
view.layer.transform = CATransform3DRotate(basicTrans, M_PI_4, 1.0f, 0.0f, 0.0f);

要实现此效果,您需要直接操作其中一个转换值(m34)。 距离越小,效果越强。然后您可以绕 x 轴进行旋转变换(倾斜),在本例中为 PI/4 或 45 度。您可以使用度 * M_PI / 180.0 计算任意值 pi。

If I understand correctly, you want to title the view backwards (into the screen) an should be able to achieve it something like this:

float distance = 50;

CATransform3D basicTrans = CATransform3DIdentity;
basicTrans.m34 = 1.0 / -distance;
view.layer.transform = CATransform3DRotate(basicTrans, M_PI_4, 1.0f, 0.0f, 0.0f);

To achieve this effect you need to manipulate one of the transformation values directly (m34). The lower distance gets, the stronger the effect gets. Then you can do the rotation transformation around the x axis (to tilt), in this case PI/4 or 45 degrees. You can calculate arbitrary values pi using degrees * M_PI / 180.0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文