• layer图层常见属性


    把layer常见图层属性总结了一下^-^欢迎大家讨论~~~~来吧 ,代码属性

    #import "CZViewController.h" @interface CZViewController () @property (nonatomic, strong) UIView *myView; @property (nonatomic, strong) UIImageView *imageView; @end @implementation CZViewController - (UIImageView *)imageView { if (_imageView == nil) { _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(110, 100, 100, 100)]; _imageView.image = [UIImage imageNamed:@"头像1"]; _imageView.backgroundColor = [UIColor redColor]; [self.view addSubview:_imageView]; } return _imageView; } - (UIView *)myView { if (_myView == nil) { _myView = [[UIView alloc] initWithFrame:CGRectMake(110, 100, 100, 100)]; _myView.backgroundColor = [UIColor redColor]; [self.view addSubview:_myView]; } return _myView; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor lightGrayColor]; [self imageView]; // 1. 阴影效果,在CA框架中不能直接使用UIKit的数据类型 //阴影颜色 self.imageView.layer.shadowColor = [UIColor yellowColor].CGColor; //阴影偏移点 // self.myView.layer.shadowOffset = CGSizeMake(-10, 10); //阴影半径 self.imageView.layer.shadowRadius = 10.0; // 图层中的Opacity相当于view的alpha属性 self.imageView.layer.shadowOpacity = 1.0; // 2. 圆角半径 // 类似于clip,使用masksToBounds阴影效果无效 self.imageView.layer.masksToBounds = YES; //图层的圆角半径 self.imageView.layer.cornerRadius = 50.0; // 3. 边框 颜色 self.imageView.layer.borderColor = [UIColor whiteColor].CGColor; //边线宽度 self.imageView.layer.borderWidth = 5.0; } - (void)viewLayerDemo { // 1. 阴影效果,在CA框架中不能直接使用UIKit的数据类型 self.myView.layer.shadowColor = [UIColor yellowColor].CGColor; // self.myView.layer.shadowOffset = CGSizeMake(-10, 10); self.myView.layer.shadowRadius = 10.0; // 图层中的Opacity相当于view的alpha属性 self.myView.layer.shadowOpacity = 1.0; // 2. 圆角半径 self.myView.layer.cornerRadius = 50.0; // 3. 边框 self.myView.layer.borderColor = [UIColor whiteColor].CGColor; self.myView.layer.borderWidth = 5.0; } @end // 设置圆角半径 _imageView.layer.cornerRadius = 75; // 阴影半径 // _imageView.layer.shadowRadius = 75; // 阴影颜色 _imageView.layer.shadowColor = [UIColor yellowColor].CGColor; // 阴影偏移位 _imageView.layer.shadowOffset = CGSizeMake( -10, 10); // 阴影不透明度(0~1)默认是0 _imageView.layer.shadowOpacity = 1; // 超出主层时添加蒙板遮盖 _imageView.layer.masksToBounds = YES; // 裁剪超出边界的内容 // _imageView.clipsToBounds = YES; // 边框线宽 _imageView.layer.borderWidth = 2; // 边框颜色 _imageView.layer.borderColor = [UIColor blueColor].CGColor; // CGRect imageVF = CGRectMake(-5, -2, _imageView.bounds.size.width + 10, _imageView.bounds.size.height + 10); // 阴影(路径)或形状 系统会高点 // _imageView.layer.shadowPath = CGPathCreateWithRect(imageVF, NULL);
  • 相关阅读:
    javax.xml.ws.WebServiceException: Provider com.sun.xml.ws.spi.ProviderImpl not found
    注意资源利用 不然导致资源消耗会很严重
    E212: 不能以写入模式打开 linux
    安装db2 提示不是有效的win32应用程序?
    对苹果“五仁”编程语言Swift的简单分析
    Spoj 1557 Can you answer these queries II 线段树 随意区间最大子段和 不反复数字
    Oracle 学习笔记 14 -- 集合操作和高级子查询
    PHP的curl库代码使用
    AWS OpsWorks新增Amazon RDS支持
    最短编辑距离算法
  • 原文地址:https://www.cnblogs.com/Ruby-Hua/p/5132004.html
Copyright © 2020-2023  润新知