• CALayer的基本使用


    1. //1.圆角
    2.     //只给父层倒圆角无效
    3.     imgView.layer.cornerRadius = 100;
    4.     //此属性可以让UIImageView的所有子图层父图层一起变化
    5.     //imgView.layer.masksToBounds = YES;
    6. //2.阴影
    7.     imgView.layer.shadowColor = [UIColor blueColor].CGColor;
    8.     imgView.layer.shadowOffset = CGSizeMake(10, 10);
    9.     imgView.layer.shadowOpacity = 0.8;

    10.//3.设置transform,形变

    1. //(1)平移
    2. //imgView.layer.transform = CATransform3DMakeTranslation(0, -100, 0);
    3. //(2)旋转
    4. //沿哪个轴旋转值就为1
    5. //imgView.layer.transform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
    6. //(3)缩放
    7. //imgView.layer.transform = CATransform3DMakeScale(0.5, 1, 1);

    18.//Documents中搜索transform3D来获取keyPath

    1. 向上移动100
    2. [imgView.layer setValue:@-100 forKeyPath:@"transform.translation.y"];
    3. 沿z轴逆时针旋转45度
    4. [imgView.layer setValue:@-M_PI_4 forKeyPath:@"transform.rotation.z"];

    25.自定义CALayer

    26.//1.必须把自定义的层添加到父图层上去显示。

    1. [self.view.layer addSublayer:myLayer];

    28.//2.设置图层的显示属性

    1. //尺寸和颜色
    2. myLayer.bounds = CGRectMake(0, 0, 200, 200);
    3. myLayer.backgroundColor = [UIColor redColor].CGColor;
    4. //显示位置,默认为中心点,具体位置由锚点决定。
    5. myLayer.position = CGPointMake(100, 100);

    34.//锚点,默认值为0.5,0.5

    1. myLayer.anchorPoint = CGPointMake(0.5, 0.5);

    36.//position和anchorPoint的值决定了层的显示位置。

    37.//Layer在放大缩小时是以锚点为中心点进行放大缩小的。

    38.UIImage *image = [UIImage imageNamed:@"2012100413195471481.jpg"];

    39.myLayer.contents = (id)image.CGImage;

    41.//淡入淡出动画,改变layer的透明度,范围是0到1。myLayer.opacity

    43.//self.view.layer是rootLayer,无隐式动画效果。//所有的非rootLayer存在隐式动画效果。

  • 相关阅读:
    tf_upgrade_v2.exe实验
    tf.random_uniform出错tensorflow2.0出错
    Tensorflow2.0变化
    Anaconda安装PyTorch
    Anaconda是如何进行版本管理的?
    CUDA开发指南
    Tensorflow视频教程&Pytorch视频教程
    Applied Spatiotemporal Data Mining应用时空数据挖掘
    GAN one-shot
    基于深度学习的图像超分辨率重建 一种基于非负矩阵分解的高光谱影像模拟方法
  • 原文地址:https://www.cnblogs.com/SilverWinter/p/4423413.html
Copyright © 2020-2023  润新知