iOS 使用UIBezierPath画线

// 创建路径
UIBezierPath *currenPath = [UIBezierPath bezierPath];
currenPath.lineCapStyle = kCGLineCapRound;
currenPath.lineJoinStyle = kCGLineJoinRound;
currenPath.lineWidth = 6;

// 设置起点
[currenPath moveToPoint:startPos];

//... 

[currentPath addLineToPoint:pos];
[self setNeedsDisplay];

//在drawRect里面, 调用stroke 画出来 
[currentPath stroke];

你可能感兴趣的:(iOS 使用UIBezierPath画线)