CAShapeLayer下方有阴影区域

时间:2013-09-26 05:41:35

标签: ios6 uiview core-animation quartz-2d cashapelayer

我正在使用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];

谢谢

0 个答案:

没有答案