把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);

layer图层常见属性的更多相关文章

  1. UIView的常见属性

    UIView的常见属性: @interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDyn ...

  2. CALayer基本介绍与常见属性

    属性框架:QuartzCore CA: CoreAnimation -> 核心动画,所有的核心动画都是添加给layer的! 与UIView的区别: 1.layer负责内容的展示,不接受任何用户交 ...

  3. iOS图片折叠效果:Layer的contentsRect属性和渐变层

    http://www.cocoachina.com/ios/20150722/12622.html 作者:@吖了个峥 授权本站转载. 前言 此次文章,讲述的是Layer的一个属性contentsRec ...

  4. CoreGraphics-线段常见属性及渲染模式介绍

    线段常见属性: 1.线宽 2.线头样式 3.接头样式 4.颜色(包括描边颜色和填充颜色) override func draw(_ rect: CGRect) { // 获取图形上下文对象 let c ...

  5. 如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可

    如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架).而若要指定某几个角(小于4)为圆角而别的不变时 ...

  6. Ext.Window 的常见属性

    Ext.Window 的常见属性:    plain:true,(默认不是)    resizable:false,(是否可以改变大小,默认可以)    maximizable:true,(是否增加最 ...

  7. UIView常见属性总结

    一 UIVIew 常见属性 .frame 位置和尺寸(以父控件的左上角为原点(,)) .center 中点 (以父控件的左上角为原点(,)) .bounds 位置和尺寸(以自己的左上角为原点 (,)) ...

  8. UISlider常见属性

    常见属性 self.mySlider.minimumValue = 0.0;   // 最小值 self.mySlider.maximumValue = 10;    // 最大值 self.mySl ...

  9. UIScrollView常见属性

    什么是UIScrollView •设备的屏幕大小是极其有限的,因此直接展示在用户眼前的内容也相当有限 • •当展示的内容较多,超出一个屏幕时,用户可通过滚动手势来查看屏幕以外的内容 • •普通的UIV ...

随机推荐

  1. linux 防火墙开放特定端口与指定ip谨防

    vi etc/iptable/sysconfig/iptables linux 开放固定端口 -A INPUT -m state --state NEW -m tcp -p tcp --dport 1 ...

  2. difference between append and appendTo

    if you need append some string to element and need set some attribute on these string at the same ti ...

  3. linux 常用命令总结

    PS命令: 1.命令格式: ps[参数] 2.命令功能: 用来显示当前进程的状态 3.命令参数: a  显示所有进程 -a 显示同一终端下的所有程序 -A 显示所有进程 c  显示进程的真实名称 -N ...

  4. 【Alpha版本】项目测试

    我说的都队 031402304 陈燊 031402342 许玲玲 031402337 胡心颖 03140241 王婷婷 031402203 陈齐民 031402209 黄伟炜 031402233 郑扬 ...

  5. 使用D3绘制图表(5)--水平柱状图表

    绘制水平柱状图表的方法也不是很难,首先在svg中插入g,然后在g中插入rect. 1.html代码 <!DOCTYPE html> <html> <head> &l ...

  6. C++_直接插入排序

    #include <iostream> using namespace std; void insertSort(int a[], int n) {     for(int i=1;i&l ...

  7. 浅谈我对JCS 的理解

    JCS 是Java 中缓存的一种实现,支持将数据缓存到内存和硬盘中,支持设置缓存对象的有效时长. 我认为可以这么理解JCS:客户端向服务器发出请求,服务器就先去缓存中查一下有没有客户端请求的数据,有则 ...

  8. java:提示Could not initialize class sun.awt.X11GraphicsEnvironment

    前几天发现tomcat提示 Could not initialize class sun.awt.X11GraphicsEnvironment  问题.以为不验证,就没太关注,今天发现,有同事提示了个 ...

  9. Python 字符串操作

    Python 字符串操作(string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分割等) 去空格及特殊符号 s.strip() .lstrip() .rstrip(',') 复制字符 ...

  10. [学习笔记]lca-倍增

    The article is to Jimmy.(方老师讲过了还不会,想怎样???) 求一棵树上两个节点的最近公共祖先有两种算法: (离线); 倍增(在线). 这篇博客只介绍倍增的写法. 表示节点的祖 ...