iOS之CALayer属性简介
/* CoreAnimation - CALayer.h Copyright (c) 2006-2017, Apple Inc.
All rights reserved. */ #import <QuartzCore/CAMediaTiming.h>
#import <QuartzCore/CATransform3D.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSNull.h>
#import <Foundation/NSArray.h>
#import <Foundation/NSDictionary.h> @class NSEnumerator, CAAnimation, CALayerArray;
@protocol CAAction, CALayerDelegate; NS_ASSUME_NONNULL_BEGIN /* Bit definitions for `edgeAntialiasingMask' property. */ typedef NS_OPTIONS (unsigned int, CAEdgeAntialiasingMask)
{
kCALayerLeftEdge = 1U << , /* Minimum X edge. */
kCALayerRightEdge = 1U << , /* Maximum X edge. */
kCALayerBottomEdge = 1U << , /* Minimum Y edge. */
kCALayerTopEdge = 1U << , /* Maximum Y edge. */
}; /* Bit definitions for `maskedCorners' property. */ typedef NS_OPTIONS (NSUInteger,
)
{
kCALayerMinXMinYCorner = 1U << ,
kCALayerMaxXMinYCorner = 1U << ,
kCALayerMinXMaxYCorner = 1U << ,
kCALayerMaxXMaxYCorner = 1U << ,
}; /** The base layer class. **/ CA_CLASS_AVAILABLE (10.5, 2.0, 9.0, 2.0)
@interface CALayer : NSObject <NSSecureCoding, CAMediaTiming>
{
@private
struct _CALayerIvars {
int32_t refcount;
uint32_t magic;
void *layer;
#if TARGET_OS_MAC && !TARGET_RT_64_BIT
void * _Nonnull unused1[];
#endif
} _attr;
} /** Layer creation and initialization. **/
//初始化方法
+ (instancetype)layer;
- (instancetype)init;
- (instancetype)initWithLayer:(id)layer; //presentationLayer是通过modelLayer提供属性进行绘制的
//呈现层 用于显示动画
- (nullable instancetype)presentationLayer; //模型层 设置的layer属性就是在这个层
- (instancetype)modelLayer; /** Property methods. **/ //重写修改CALayer或其子类的默认值 ,key为属性名称,如果没有该属性返回nil
+ (nullable id)defaultValueForKey:(NSString *)key; //需要子类重写,当CALayer或其子类属性被修改时调用此方法
//key为修改的属性名,返回YES是系统自动调用-display方法
+ (BOOL)needsDisplayForKey:(NSString *)key; //指示指定键的值是否应该归档。
- (BOOL)shouldArchiveValueForKey:(NSString *)key; //layer的大小
@property CGRect bounds; //设置CALayer在父层中的位置
@property CGPoint position; //z方向的位置
@property CGFloat zPosition; //平面上的锚点(0-1),决定layer身上的哪个点在position的位置上
@property CGPoint anchorPoint; //z方向上的锚点
@property CGFloat anchorPointZ; //矩阵 仿射变换
@property CATransform3D transform; //返回和设置仿射变换值
- (CGAffineTransform)affineTransform;
- (void)setAffineTransform:(CGAffineTransform)m; //设置layer的坐标
@property CGRect frame; //是否隐藏
@property(getter=isHidden) BOOL hidden; //设置layer的背面是否被绘制,默认是YES,NO时当图层从相机视角消失是将不会被绘制。
@property(getter=isDoubleSided) BOOL doubleSided; //默认为NO,设置为YES所有子图层相对于左上角的位置改为相对于左下角位置
@property(getter=isGeometryFlipped) BOOL geometryFlipped; //获取当前layer内容在Y轴方向是否被翻转了
- (BOOL)contentsAreFlipped; //获取父层layer
@property(nullable, readonly) CALayer *superlayer; //从父层layer上移除
- (void)removeFromSuperlayer; //获取所有子layer数组
@property(nullable, copy) NSArray<CALayer *> *sublayers; //将layer添加到父视图
- (void)addSublayer:(CALayer *)layer; //插入一个layer
- (void)insertSublayer:(CALayer *)layer atIndex:(unsigned)idx;
- (void)insertSublayer:(CALayer *)layer below:(nullable CALayer *)sibling;
- (void)insertSublayer:(CALayer *)layer above:(nullable CALayer *)sibling; //用layer2替换layer
- (void)replaceSublayer:(CALayer *)layer with:(CALayer *)layer2; //对子layer进行3D变换
@property CATransform3D sublayerTransform; //图层蒙版layer
@property(nullable, strong) CALayer *mask; //是否进行bounds切割,通常设置圆角时使用
@property BOOL masksToBounds; /** Mapping between layer coordinate and time spaces. **/
//转换坐标点、矩形
- (CGPoint)convertPoint:(CGPoint)p fromLayer:(nullable CALayer *)l;
- (CGPoint)convertPoint:(CGPoint)p toLayer:(nullable CALayer *)l;
- (CGRect)convertRect:(CGRect)r fromLayer:(nullable CALayer *)l;
- (CGRect)convertRect:(CGRect)r toLayer:(nullable CALayer *)l;
//转换CAMediaTiming协议的相对时间
- (CFTimeInterval)convertTime:(CFTimeInterval)t fromLayer:(nullable CALayer *)l;
- (CFTimeInterval)convertTime:(CFTimeInterval)t toLayer:(nullable CALayer *)l; /** Hit testing methods. **/ //返回包含某一点的最上层的子layer
- (nullable CALayer *)hitTest:(CGPoint)p; //判断layer是否包含某一点
- (BOOL)containsPoint:(CGPoint)p; /** Layer content properties and methods. **/ //设置layer的内容 ,一般设置CGImage的对象
@property(nullable, strong) id contents; //获取内容的rect尺寸
@property CGRect contentsRect; //设置内容对齐和填充方式(枚举)
@property(copy) NSString *contentsGravity; //设置内容的缩放
@property CGFloat contentsScale
CA_AVAILABLE_STARTING (10.7, 4.0, 9.0, 2.0); //设置一个矩形变形区域默认(0,0,1,1)取值0-1
@property CGRect contentsCenter; //设置内容存储格式
@property(copy) NSString *contentsFormat
CA_AVAILABLE_STARTING (10.12, 10.0, 10.0, 3.0); //设置缩小和放大模式
@property(copy) NSString *minificationFilter;
@property(copy) NSString *magnificationFilter; //缩放因子
@property float minificationFilterBias; //设置内容完全不透明 默认NO
@property(getter=isOpaque) BOOL opaque; //重新加载绘制内容
- (void)display; // 设置内容或某一区域内容加载
- (void)setNeedsDisplay;
- (void)setNeedsDisplayInRect:(CGRect)r; //获取是否需要重新绘制
- (BOOL)needsDisplay; //如果需要进行内容重新绘制
- (void)displayIfNeeded; //设置为YES 内容改变后自动调用 - (void)setNeedsDisplay;方法
@property BOOL needsDisplayOnBoundsChange; //延迟绘制命令,用于需要频繁重绘的视图
@property BOOL drawsAsynchronously
CA_AVAILABLE_STARTING (10.8, 6.0, 9.0, 2.0); //绘制内容
- (void)drawInContext:(CGContextRef)ctx; /** Rendering properties and methods. **/ //读取内容
- (void)renderInContext:(CGContextRef)ctx; //用于限定层的边缘如何栅格化,默认是抗锯齿
@property CAEdgeAntialiasingMask edgeAntialiasingMask; //YES时,要求edgeAntialiasingMask属性边抗锯齿,默认值是从Info.plist中UIViewEdgeAntialiasing属性获取,如果没有值默认NO
@property BOOL allowsEdgeAntialiasing; //设置layer背景色
@property(nullable) CGColorRef backgroundColor; //设置layer圆角半径
@property CGFloat cornerRadius; //设置layer哪几个角显示圆角 支持动画
@property CACornerMask maskedCorners
CA_AVAILABLE_STARTING (10.13, 11.0, 11.0, 4.0); //设置边框宽度
@property CGFloat borderWidth; //设置边框颜色
@property(nullable) CGColorRef borderColor; //设置透明度
@property float opacity; //默认YES(iOS7之后)子layer最高透明度上限是父layer的透明度,NO各自控制
@property BOOL allowsGroupOpacity; //一个coreImage过滤器 用于合成图层及其后面内容 可动画
@property(nullable, strong) id compositingFilter; //应用于图层和其子图层内容的coreImage过滤器数组
@property(nullable, copy) NSArray *filters; //应用于图层后面的内容的coreImage过滤器数组 可动画
@property(nullable, copy) NSArray *backgroundFilters; //光栅化
@property BOOL shouldRasterize; //当shouldRasterize设置为YES是,也就是光栅化之后 设置此属性防止retina屏幕像素化(默认值1)
@property CGFloat rasterizationScale; /** Shadow properties. **/ //阴影颜色 可动画
@property(nullable) CGColorRef shadowColor; //阴影透明度 可动画
@property float shadowOpacity; //阴影偏移量 可动画
@property CGSize shadowOffset; //阴影圆角半径 可动画
@property CGFloat shadowRadius; //阴影路径 可动画
@property(nullable) CGPathRef shadowPath; /** Layout methods. **/ //返回图层在其父图层的坐标空间中的首选大小
- (CGSize)preferredFrameSize; //使图层无效,标记需要更新
- (void)setNeedsLayout; //返回是否需要布局更新标志
- (BOOL)needsLayout; //如果需要,重新计算布局
- (void)layoutIfNeeded; //重新布局所有子layer
- (void)layoutSublayers; /** Action methods. **/ //返回当前类的默认操作
+ (nullable id<CAAction>)defaultActionForKey:(NSString *)event; //返回分配给指定键的动作对象
- (nullable id<CAAction>)actionForKey:(NSString *)event; //包含图层动作的字典
@property(nullable, copy) NSDictionary<NSString *, id<CAAction>> *actions; /** Animation methods. **/ //给layer渲染树添加指定动画对象
- (void)addAnimation:(CAAnimation *)anim forKey:(nullable NSString *)key; //移除所有动画对象
- (void)removeAllAnimations; //移除指定动画对象
- (void)removeAnimationForKey:(NSString *)key; //返回字符串数组,标记当前layer附加的所有动画
- (nullable NSArray<NSString *> *)animationKeys; //通过指定的标识返回一个动画对象
- (nullable CAAnimation *)animationForKey:(NSString *)key; /** Miscellaneous properties. **/ //图层标识
@property(nullable, copy) NSString *name; //代理
@property(nullable, weak) id <CALayerDelegate> delegate; //一个用于存储未由图层显示定义的属性值的可选字典
@property(nullable, copy) NSDictionary *style; @end /** Action (event handler) protocol. **/ @protocol CAAction //CAAction协议方法(action对象 隐式动画)
- (void)runActionForKey:(NSString *)event object:(id)anObject
arguments:(nullable NSDictionary *)dict; @end /** NSNull protocol conformance. **/ @interface NSNull (CAActionAdditions) <CAAction> @end /** Delegate methods. **/ @protocol CALayerDelegate <NSObject>
@optional //更新图层时回调
- (void)displayLayer:(CALayer *)layer; //绘制图层时回调
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx; //图层将要绘制是回调
- (void)layerWillDraw:(CALayer *)layer
CA_AVAILABLE_STARTING (10.12, 10.0, 10.0, 3.0); //子layer布局时回调
- (void)layoutSublayersOfLayer:(CALayer *)layer; //执行指定操作时回调
- (nullable id<CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event; @end /** Layer `contentsGravity' values. **/ CA_EXTERN NSString * const kCAGravityCenter
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityTop
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityBottom
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityLeft
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityRight
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityTopLeft
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityTopRight
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityBottomLeft
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityBottomRight
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityResize
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityResizeAspect
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAGravityResizeAspectFill
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0); /** Layer `contentsFormat` values. **/ CA_EXTERN NSString * const kCAContentsFormatRGBA8Uint /* RGBA UInt8 per component */
CA_AVAILABLE_STARTING (10.12, 10.0, 10.0, 3.0);
CA_EXTERN NSString * const kCAContentsFormatRGBA16Float /* RGBA half-float 16-bit per component */
CA_AVAILABLE_STARTING (10.12, 10.0, 10.0, 3.0);
CA_EXTERN NSString * const kCAContentsFormatGray8Uint /* Grayscale with alpha (if not opaque) UInt8 per component */
CA_AVAILABLE_STARTING (10.12, 10.0, 10.0, 3.0); /** Contents filter names. **/ CA_EXTERN NSString * const kCAFilterNearest
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAFilterLinear
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0); /* Trilinear minification filter. Enables mipmap generation. Some
* renderers may ignore this, or impose additional restrictions, such
* as source images requiring power-of-two dimensions. */ CA_EXTERN NSString * const kCAFilterTrilinear
CA_AVAILABLE_STARTING (10.6, 3.0, 9.0, 2.0); /** Layer event names. **/ CA_EXTERN NSString * const kCAOnOrderIn
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0);
CA_EXTERN NSString * const kCAOnOrderOut
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0); /** The animation key used for transitions. **/ CA_EXTERN NSString * const kCATransition
CA_AVAILABLE_STARTING (10.5, 2.0, 9.0, 2.0); NS_ASSUME_NONNULL_END
iOS之CALayer属性简介的更多相关文章
- iOS之CAGradientLayer属性简介和使用
1.CAGradientLayer简介 CAGradientLayer用于制作背景图层的颜色渐变,也就是颜色梯度!相关属性简介: #import <QuartzCore/CALayer.h> ...
- iOS之CAScrollLayer属性简介和使用
1.CAScrollLayer的简介 CAScrollLayer用于显示一个滑动图层的一部分,可以确定滑动方向和可视区域面积,限制不滑出区域外!相关属性如下:其中 /* Scroll the cont ...
- iOS之CAReplicatorLayer属性简介和使用
1.CAReplicatorLayer简介 CAReplicatorLayer用于对图层进行复制,包括图层的动画也能复制!可以看着将某一段事务进行重复! #import <QuartzCore/ ...
- iOS之CATextLayer属性简介
1.CATextLayer简介 CATextLayer快速高效简单地来渲染纯文本.NSAttributedString /* The text layer provides simple text l ...
- iOS之CAShapeLayer属性简介
1.CAShapeLayer需要和贝塞尔曲线一块使用! #import <QuartzCore/CALayer.h> NS_ASSUME_NONNULL_BEGIN CA_CLASS_AV ...
- iOS基础 - CALayer
一.CALayer简介 Core Animation是跨平台的,支持iOS环境和Mac OS X环境 凡是支持跨平台的框架,都不能直接使用UIKit框架,因为UIKit框架只能应用在iOS而不能用于M ...
- [iOS Animation]-CALayer 视觉效果
视觉效果 嗯,圆和椭圆还不错,但如果是带圆角的矩形呢? 我们现在能做到那样了么? 史蒂芬·乔布斯 我们在第三章『图层几何学』中讨论了图层的frame,第二章『寄宿图』则讨论了图层的寄宿图.但是图层不仅 ...
- [转]IOS UIView 之属性篇
[转载自:IOS UIView 之属性篇 From CSDN] UIView 继承于UIResponder 所遵守的协议有 NSCoding .UIAppearance. UI ...
- iOS开发-automaticallyAdjustsScrollViewInsets属性
iOS开发-automaticallyAdjustsScrollViewInsets属性 Available in iOS 7.0 and later. 简单点说就是automaticallyAdju ...
随机推荐
- luogu3384 /// 树链剖分+线段树模板
题目大意: https://www.luogu.org/problemnew/show/P3384 树链剖分的讲解 两个dfs() 修改 查询 很详细很好理解 https://www.cnblogs. ...
- docker删除常见命令
$ docker stop $(docker ps -a | grep "Exited" | awk '{print $1 }') //停止容器 1b7067e19d6f a840 ...
- 《移山之道》第十一章:两人合作 读书笔记 PB16110698 第六周(~4.15)
本周在考虑阅读材料时,我翻阅了<移山之道>,正好看到这一章:两人合作,心想:正好,我们正值结对作业的紧要关头,书中两人合作的宝贵经验和教诲应当对我们有很大帮助.于是,我开始一边在ddl苦 ...
- ubuntu 权限不够,解决办法,无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
终端执行 sudo passwd root输入root 新密码执行命令 nano /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf末行添加 gr ...
- Sublime Text最舒服的主题
Theme - Afterglow (官网链接) 贴上 preferences -> settings 里面的配置 { "theme": "Afterglow-gr ...
- 混合云存储组合拳:基于云存储网关与混合云备份的OSS数据备份方案
前言 阿里云对象存储(OSS)用户众多.很多用户因为业务或者合规性需求,需要对OSS内的数据做备份,无论是线上备份,还是线下备份.用户可以选择使用OSS的开放API,按照业务需求,做数据的备份,也可以 ...
- 暑假集训test-8-14~8-15
我不想写博客辣. 拖了三天的一起写,结果就是写不下去了...果然应该改一道写一道么.. 题面题解代码也懒得往博客上放了,屯U盘里了... 因为太菜还有两道没有改. 题解外的一些参考: lyc大佬的进程 ...
- VS2010-MFC(对话框:字体对话框)
转自:http://www.jizhuomi.com/software/175.html 字体对话框的作用是用来选择字体.我们也经常能够见到.MFC使用CFontDialog类封装了字体对话框的所有操 ...
- Keras+Yolo 目标检测
参考:https://www.cnblogs.com/tensorflownews/p/8922359.html Github:https://github.com/qqwweee/keras-yol ...
- Docker系列(九):Kubernetes架构深度解析
Kubernetes重要概念 Docker解决了打包和隔离的问题,但我们需要更多:调度的问题,生命周期及健康状况,服务发现,监控,认证,容器聚合. Kubernetes概述 开源DOcker容器编排系 ...