请问如何在ios中绘制一条荧光线呢?尝试了好多方法都不可行,感谢,感谢
之前使用UIBezierPath来画线
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
//获取触摸点
UITouch *touch = touches.anyObject;
CGPoint locp = [touch locationInView:touch.view];
//创建路径
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:locp];
path.lineCapStyle = kCGLineCapRound;
path.lineJoinStyle = kCGLineJoinRound;
path.lineWidth = 2;
//
[self.arrM addObject:path];
}
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
UITouch *touch = touches.anyObject;
CGPoint locp2 = [touch locationInView:touch.view];
[self.arrM.lastObject addLineToPoint:locp2];
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect {
for (UIBezierPath *bez in self.arrM) {
[[UIColor redColor] set];
[bez stroke];
}
}