Ios UIBezierPath在触摸时用两个手指移动绘制线

Ios UIBezierPath在触摸时用两个手指移动绘制线,ios,uibezierpath,Ios,Uibezierpath,如何在使用UIBezierPath移动的触摸屏中绘制线?当我试图用两个触碰/手指画一条线时,它正在画,但它画了多条线。我尝试删除lastObjectIndex,也尝试删除AllObject,但结果仍然相同。我只想从手指1到手指2画一条线,当用户松开手指时,这条线将在UIImageView上画出来。这是我的密码: -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if ([drawMode isEqualTo

如何在使用UIBezierPath移动的触摸屏中绘制线?当我试图用两个触碰/手指画一条线时,它正在画,但它画了多条线。我尝试删除lastObjectIndex,也尝试删除AllObject,但结果仍然相同。我只想从手指1到手指2画一条线,当用户松开手指时,这条线将在UIImageView上画出来。这是我的密码:

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    if ([drawMode isEqualToString:@"stroke"]) {
        UITouch *touch=[[touches allObjects] objectAtIndex:0];
        [myPath addLineToPoint:[touch locationInView:self]];
    }
    else if ([drawMode isEqualToString:@"line"]) {
        NSArray *allTouches = [touches allObjects];
        if ([touches count] == 2) {
            UITouch *touch1 = [allTouches objectAtIndex:0];
            UITouch *touch2 = [allTouches objectAtIndex:1];
            CGPoint touchLoc1 = [touch1 locationInView:self];
            CGPoint touchLoc2 = [touch2 locationInView:self];
            [myPath moveToPoint:touchLoc1];
            [myPath addLineToPoint:touchLoc2];
            [shapeArray removeAllObjects];
            [shapeArray addObject:myPath];
        }
    }

    [self setNeedsDisplay];
}

废话少说。显示一些代码以便我们可以提供帮助。我已经添加了一些代码。我正在考虑使用Quartz 2D/CGContextAddLineToPoint进行绘制,但我的应用程序上没有显示任何内容。可能是因为我使用的是自定义UIView?