Objective-C CALayer UIView实际旋转 [英] Objective-C CALayer UIView real rotation

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

问题描述

我正在尝试旋转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). distance越低,效果越强.然后,您可以绕x轴进行旋转变换(倾斜),在这种情况下为PI/4或45度.您可以使用degrees * 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-C CALayer UIView实际旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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