objective-сCALayerUIView实际旋转 [英] objective-с CALayer UIView real rotation

查看:116
本文介绍了objective-сCALayerUIView实际旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试旋转UIView对象,如下图所示
http://i.piccy.info/i7/f8ff7fe488c7c492e6ff6a689bc9cdeb/1-5-2127/60800682/rotation.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

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

有人可以帮帮我吗?

推荐答案

如果我理解正确,你想向后标题视图(进入屏幕)应该能够达到这样的目的:

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

要实现此效果,您需要直接操作其中一个转换值(m34)。较低的距离获得,效果越强。然后你可以围绕x轴(倾斜)进行旋转变换,在这种情况下PI / 4或45度。您可以使用度* M_PI / 180.0 计算任意值pi。

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.

这篇关于objective-сCALayerUIView实际旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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