zoukankan      html  css  js  c++  java
  • CALayer

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

     
  • 相关阅读:
    记忆化搜索 E
    网络流 O
    线段树 B数据结构 牛客练习赛28
    N
    线段树 G
    K
    F
    补一下昨天的博客 J
    selenium-1-python
    selenium入门知识
  • 原文地址:https://www.cnblogs.com/buakaw/p/5725682.html
Copyright © 2011-2022 走看看