我想为我的应用程序创建一个工具,首先绘制直线,然后在第二个触摸和移动用户可以创建可调整的曲线线。 所以这个想法是当用户触摸并且第二次移动时设置曲线的中间点。绘制直线并创建曲线拖动线
而且我不知道如何检查第二次触摸并使用以前的路径。
这种方法我用来画简单的线
谢谢!
- (void)setInitialPoint:(CGPoint)firstPoint
{
self.firstPoint = firstPoint;
//[self moveToPoint:firstPoint]; //add yourStartPoint here
///[self addLineToPoint:endPoint];
}
- (void)moveFromPoint:(CGPoint)startPoint toPoint:(CGPoint)endPoint
{
self.lastPoint = endPoint;
// [self addLineToPoint:self.lastPoint];// add yourEndPoint here
}
- (void)draw {
UIBezierPath *path = [UIBezierPath bezierPath];
//draw a line
[path moveToPoint:self.firstPoint]; //add yourStartPoint here
[path addLineToPoint:self.lastPoint];// add yourEndPoint here
[self.lineColor setStroke];
[path setLineWidth:3.0];
[path stroke];
}
谢谢,@Wain。只需要找出如何跟踪触摸..因为我有其他乐器(如虚线,箭头),对他们我只需要一个接触。 –
UIGestureRecofnizer或UIView(touchesBegan :)。 – Wain