iOS 官方文档CALayer

来源:互联网 发布:java大量数据处理调优 编辑:程序博客网 时间:2024/05/16 11:43

一、创建一个层

1、+ layer

(1) 方法原型

+ (instancetype)layer

2、- init

(1) 方法原型

- (instancetype)init

3、- initWithLayer:

(1) 方法原型

- (instancetype)initWithLayer:(id)layer

二、访问相关层对象

1、- presentationLayer

(1) 方法原型

- (id)presentationLayer

2、- modelLayer

(1) 方法原型

- (id)modelLayer

三、相关的Delegate

1、delegate

(1) 方法原型

@property(weak) id delegate

四、提供层的内容

1、contents

(1) 方法原型

@property(strong) id contents//图层显示内容,例如可以将图片作为图层内容显示

2、contentsRect

(1) 方法原型

@property CGRect contentsRect//图层显示内容的大小和位置

3、contentsRect

(1) 方法原型

@property CGRect contentsCenter

4、- display

(1) 方法原型

- (void)display

5、- drawInContext:

(1) 方法原型

- drawInContext:

四、修改层的外观

1、contentsGravity

(1) 方法原型

@property(copy) NSString *contentsGravity

2、opacity

(1) 方法原型

@property float opacity//UIView 的透明效果

3、hidden

(1) 方法原型

@property(getter=isHidden) BOOL hidden//是否隐藏

4、masksToBounds

(1) 方法原型

@property BOOL masksToBounds// 子图层是否剪切图层边界,默认为NO

5、mask

(1) 方法原型

@property(strong) CALayer *mask//图层蒙版

6、doubleSided

(1) 方法原型

@property(getter=isDoubleSided) BOOL doubleSided//图层背面是否显示,默认为YES

7、cornerRadius

(1) 方法原型

@property CGFloat cornerRadius//UIView 的圆角

8、borderWidth

(1) 方法原型

@property CGFloat borderWidth//边框宽度

9、borderColor

(1) 方法原型

@property CGColorRef borderColor//边框颜色

10、backgroundColor

(1) 方法原型

@property CGColorRef backgroundColor

11、shadowOpacity

(1) 方法原型

@property float shadowOpacity// shadow 的透明效果

12、shadowRadius

(1) 方法原型

@property CGFloat shadowRadius//阴影模糊半径

13、shadowOffset

(1) 方法原型

@property CGSize shadowOffset//阴影偏移量

14、shadowColor

(1) 方法原型

@property CGColorRef shadowColor//阴影颜色

15、shadowPath

(1) 方法原型

@property CGPathRef shadowPath//阴影的形状

16、style

(1) 方法原型

@property(copy) NSDictionary *style

17、allowsEdgeAntialiasing

(1) 方法原型

@property BOOL allowsEdgeAntialiasing

18、allowsGroupOpacity

(1) 方法原型

@property BOOL allowsGroupOpacity

五、访问层的过滤器

1、allowsGroupOpacity

(1) 方法原型

@property(copy) NSArray *filters

2、compositingFilter

(1) 方法原型

@property(strong) id compositingFilter

3、backgroundFilters

(1) 方法原型

@property(copy) NSArray *backgroundFilters

4、minificationFilter

(1) 方法原型

@property(copy) NSString *minificationFilter

5、minificationFilterBias

(1) 方法原型

@property float minificationFilterBias

6、magnificationFilter

(1) 方法原型

@property(copy) NSString *magnificationFilter

六、管理层的变换

1、transform

(1) 方法原型

@property CATransform3D transform

2、sublayerTransform

(1) 方法原型

@property CATransform3D sublayerTransform

3、- affineTransform

(1) 方法原型

- (CGAffineTransform)affineTransform

4、- setAffineTransform:

(1) 方法原型

- (void)setAffineTransform:(CGAffineTransform)m

七、更新层显示

1、- setNeedsDisplay

(1) 方法原型

- (void)setNeedsDisplay

2、- setNeedsDisplayInRect:

(1) 方法原型

- (void)setNeedsDisplayInRect:(CGRect)theRect

3、needsDisplayOnBoundsChange

(1) 方法原型

@property BOOL needsDisplayOnBoundsChange

4、- displayIfNeeded

(1) 方法原型

- (void)displayIfNeeded

5、- needsDisplay

(1) 方法原型

- (BOOL)needsDisplay

6、+ needsDisplayForKey:

(1) 方法原型

+ (BOOL)needsDisplayForKey:(NSString *)key

八、层动画

1、- addAnimation:forKey:

(1) 方法原型

- (void)addAnimation:(CAAnimation *)anim              forKey:(NSString *)key

2、- animationForKey:

(1) 方法原型

- (CAAnimation *)animationForKey:(NSString *)key

3、- removeAllAnimations

(1) 方法原型

- (void)removeAllAnimations

4、- removeAnimationForKey:

(1) 方法原型

- (void)removeAnimationForKey:(NSString *)key

5、- animationKey

(1) 方法原型

- (NSArray<NSString *> *)animationKey

九、管理层布局和调整

1、- setNeedsLayout

(1) 方法原型

- (void)setNeedsLayout

2、- layoutSublayers

(1) 方法原型

- (void)layoutSublayers

3、- layoutIfNeeded

(1) 方法原型

- (void)layoutIfNeeded

4、- needsLayout

(1) 方法原型

- (BOOL)needsLayout

5、- preferredFrameSize

(1) 方法原型

- (CGSize)preferredFrameSize

十、获取层的行为

1、- actionForKey:

(1) 方法原型

- (id<CAAction>)actionForKey:(NSString *)key

2、actions

(1) 方法原型

@property(copy) NSDictionary <NSString *,id<CAAction>> *actions

3、+ defaultActionForKey:

(1) 方法原型

+ (id<CAAction>)defaultActionForKey:(NSString *)key

十一、坐标和时间空间之间的映射

1、- convertPoint:fromLayer:

(1) 方法原型

- (CGPoint)convertPoint:(CGPoint)aPoint              fromLayer:(CALayer *)layer

2、- convertPoint:toLayer:

(1) 方法原型

- (CGPoint)convertPoint:(CGPoint)aPoint                toLayer:(CALayer *)layer

3、- convertRect:fromLayer:

(1) 方法原型

- (CGRect)convertRect:(CGRect)aRect            fromLayer:(CALayer *)layer

4、- convertRect:toLayer:

(1) 方法原型

- (CGRect)convertRect:(CGRect)aRect              toLayer:(CALayer *)layer

5、- convertTime:fromLayer:

(1) 方法原型

- (CFTimeInterval)convertTime:(CFTimeInterval)timeInterval                    fromLayer:(CALayer *)layer

6、- convertTime:toLayer:

(1) 方法原型

- (CFTimeInterval)convertTime:(CFTimeInterval)timeInterval                      toLayer:(CALayer *)layer

十二、冲击测试

1、- hitTest:

(1) 方法原型

- (CALayer *)hitTest:(CGPoint)thePoint

2、- containsPoint:

(1) 方法原型

- (BOOL)containsPoint:(CGPoint)thePoint

十三、滑动

1、visibleRect

(1) 方法原型

@property(readonly) CGRect visibleRect

2、- scrollPoint:

(1) 方法原型

- (void)scrollPoint:(CGPoint)thePoint

3、- scrollRectToVisible:

(1) 方法原型

- (void)scrollRectToVisible:(CGRect)theRect

十四、识别层

1、name

(1) 方法原型

@property(copy) NSString *name

十五、键值编码扩展

1、- shouldArchiveValueForKey:

(1) 方法原型

- (BOOL)shouldArchiveValueForKey:(NSString *)key

2、+ defaultValueForKey:

(1) 方法原型

+ (id)defaultValueForKey:(NSString *)key
0 0
原创粉丝点击