码迷,mamicode.com
首页 > 其他好文 > 详细

CALayer

时间:2016-08-01 15:44:12      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:

 

CALayer

1.3D变换中的透视效果,由矩阵中的m34元素控制,用于按比例缩放x、y,以此计算离视角有多远。m34默认值是0,通过设置 m34 = -1.0 / d 来应用透视效果,d代表视角相机与屏幕的距离,单位是像素,其值一般为 500 ~ 1000
例如旋转一个3D方块,使其呈现透视效果。

- (void)pan:(UIPanGestureRecognizer *)g {
CGPoint p = [g translationInView:self.view];

CATransform3D transform = CATransform3DIdentity;
transform.m34 = -1.0 / 2000;

transform = CATransform3DRotate(transform, 0.01 * p.x, 0, 1, 0); // x 值变化是随着y轴旋转
transform = CATransform3DRotate(transform, -0.01 * p.y, 1, 0, 0); // y 值变化是随着x轴旋转

self.view.layer.sublayerTransform = transform;
}

 

CALayer

标签:

原文地址:http://www.cnblogs.com/buakaw/p/5725682.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!