CAShapeLayer(形状图层)
CAShapeLayer所有独有的属性
//图形层路径
@property(nullable) CGPathRef path;
//图形层颜色
@property(nullable) CGColorRef fillColor;
@property(copy) NSString *fillRule;
//描边颜色
@property(nullable) CGColorRef strokeColor;
@property CGFloat strokeStart;
@property CGFloat strokeEnd;
//线宽
@property CGFloat lineWidth;
@property CGFloat miterLimit;
@property(copy) NSString *lineCap;
@property(copy) NSString *lineJoin;
@property CGFloat lineDashPhase;
@property(nullable, copy) NSArray<NSNumber *> *lineDashPattern;
CAShapeLayer用于图形层懒加载
- (CAShapeLayer *)shapeLayer
{
if (_shapeLayer == nil) {
// 可以根据路径生成图层
CAShapeLayer *layer = [CAShapeLayer layer];
##核心代码
//设置填充颜色
layer.fillColor = [UIColor redColor].CGColor;
[self.superview.layer insertSublayer:layer atIndex:0];
_shapeLayer = layer;
##
}
return _shapeLayer;
}
网友评论