Code to generate lines:
self.path = [UIBezierPath bezierPath];
[self.path moveToPoint:from];
[self.path addLineToPoint:to];
self.pathLayer = [CAShapeLayer layer];
self.pathLayer.frame = containerView.bounds;
self.pathLayer.path = self.path.CGPath;
self.pathLayer.strokeColor = color.CGColor;
self.pathLayer.lineWidth = 2.0f;
self.pathLayer.lineJoin = kCALineJoinBevel;
NSMutableArray *ary = [NSMutableArray arrayWithArray:shapeLayers];
[ary addObject:self.pathLayer];
shapeLayers = [NSMutableArray arrayWithArray:ary];
[containerView.layer addSublayer:self.pathLayer];
How to delete the above line and draw a new one
我想大声告诉你2017-05-02 09:31:25
Add
before self.pathLayer = [CAShapeLayer layer];
if (self.pathLayer) {
[self.pathLayer removeFromSuperlayer];
}