objective-c - iOS UIBezierPath畫線如何刪除現有的線
为情所困
为情所困 2017-05-02 09:29:25
0
1
1215

產生線的程式碼:
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];

如何將上述線刪除,在畫新線

为情所困
为情所困

全部回覆(1)
我想大声告诉你

self.pathLayer = [CAShapeLayer layer];之前加上

if (self.pathLayer) {
        [self.pathLayer removeFromSuperlayer];
    }
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板