Rozciągliwa linia UIBezierPath?

Chcę narysować palcem linię prostą, która automatycznie zmienia rozmiar na podstawie tego, jak daleko jestem od punktu początkowego.

Jeśli więc dotknę ekranu na środku i wysunę palec z linii, pojawi się „rozciągnięcie” i obrót wokół punktu, gdy mój palec porusza się po ekranie. Kiedy podniosę palec. Punkt docelowy powinien sfinalizować i utworzyć linię. Mogę przeciągać palcem po ekranie i rysować na ekranie, ale to nie jest to, co chcę robić.

Pomyślałem, że UIBeizerPath moveToPoint może pomóc, ale po prostu powoduje problemy.

Co ja robię źle?

- (id)initWithFrame:(CGRect)frame
{
     //default line properties
    myPath=[[UIBezierPath alloc]init];
    myPath.lineCapStyle=kCGLineCapRound;
    myPath.miterLimit=0;
    myPath.lineWidth=lineWidth;
    brushPattern=[UIColor blackColor];
 }



-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    CGPoint curPoint = [[touches anyObject] locationInView:self];

    lastPoint = curPoint;

    [myPath moveToPoint:lastPoint];
    [pathArray addObject:myPath];
    [self setNeedsDisplay];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

    CGPoint curPoint = [[touches anyObject] locationInView:self];

    myPath.lineWidth=lineWidth;
    brushPattern=[UIColor redColor]; //red to show it hasn't been added yet.
    [myPath moveToPoint:tempPoint];
    [self setNeedsDisplay];
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

    CGPoint curPoint = [[touches anyObject] locationInView:self];

    myPath.lineWidth=lineWidth;

    brushPattern=[UIColor blackColor]; //finalize the line with black color
    [myPath addLineToPoint:curPoint];
    [self setNeedsDisplay];
}

questionAnswers(2)

yourAnswerToTheQuestion