我正在使用 CAShapeLayer 绘制一条图形线,现在我想填充 CAShapeLayer 创建的那条线下方的区域?我已经尝试过 CAShapeLayer 阴影、渐变,但它不起作用,请指导我正确的方法来实现这一点。我的代码如下:
//1. Create bezier path from first point to second.
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:firstPoint];
[path addLineToPoint:secondPoint];
//2. Create a shape layer for above created path.
myLayer = [[CAShapeLayer alloc] init];
myLayer.strokeColor = [[UIColor whiteColor] CGColor];
myLayer.lineWidth = 3.0;
myLayer.lineJoin = kCALineJoinRound;
myLayer.lineCap = kCALineCapRound;
myLayer.shadowColor = [UIColor redColor].CGColor;
myLayer.path = path.CGPath;
myLayer.shadowOpacity = 0.8;
myLayer.shadowRadius = 12;
myLayer.masksToBounds = NO;
myLayer.shadowOffset = CGSizeMake(-15, 20);
myLayer.shadowRadius = 50;
myLayer.shadowOpacity = 0.5;
[drawnLayersArray addObject:myLayer];
[self.scroll.layer addSublayer:myLayer];
谢谢