CALayer

来源:互联网 发布:知与行杂志官网 编辑:程序博客网 时间:2024/06/03 05:31

@interface UIView : UIResponder

@property(nonatomic,readonly,strong)                 CALayer  *layer; 

@interface CALayer : NSObject

//背景颜色@property(nullable) CGColorRef backgroundColor;//圆角半径@property CGFloat cornerRadius;//边框颜色@property(nullable) CGColorRef borderColor;//边框厚度@property CGFloat borderWidth;//阴影//阴影颜色@property(nullable) CGColorRef shadowColor;//阴影颜色比重(阴影颜色透明度)@property float shadowOpacity;//阴影偏移值@property CGSize shadowOffset;//内容@property(nullable, strong) id contents;//设置为YES(1)内容会与边角保持一致(2)阴影消失@property BOOL masksToBounds;//锚点//1 若position,anchorPoint都没设置,layer位置不变,锚点默认为layer的中心,旋转围绕中心//2 若设置了position,没设置anchorPoint,anchorPoint默认为(0.5,0.5)layer位置改变,以position为中心//3 若设置了position,anchorPoint,则按照锚点在x,y上的位置进行移动//锚点坐标@property CGPoint position;//锚点在图层x,y的位置@property CGPoint anchorPoint;//动画//1 围绕锚点动画//2 进行动画的时候有一个隐式动画,自带动画效果//-----------直接动画-------------@property CATransform3D transform;//平移CATransform3D CATransform3DMakeTranslation (CGFloat tx,    CGFloat ty, CGFloat tz)//旋转//angle 旋转角度//x,y,z为是否旋转0或者1CATransform3D CATransform3DMakeRotation (CGFloat angle, CGFloat x,    CGFloat y, CGFloat z)//缩放(sx,sy,sz为各个方向上的倍数)CATransform3D CATransform3DMakeScale (CGFloat sx, CGFloat sy,    CGFloat sz)//----------KVO动画-----------------//key Path:搜索官方文档CATransform3D Key Paths//围绕z轴旋转45度[view.layer setValue:@(M_PI_4) forKeyPath:@"transform.rotation.y"];

@interface NSObject (CALayerDelegate)

//,签署代理,设置代理对象,覆写可在layer上进行绘画- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx;
0 0