我想爲我的應用程序創建一個工具,首先繪製直線,然後在第二個觸摸和移動用戶可以創建可調整的曲線線。 所以這個想法是當用戶觸摸並且第二次移動時設置曲線的中間點。繪製直線並創建曲線拖動線
而且我不知道如何檢查第二次觸摸並使用以前的路徑。
這種方法我用來畫簡單的線
謝謝!
- (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