2016-12-07 9 views
0

下の画像では、私は描画し、結果は点Aにあります。右のところで私の指が触れています。UITouchesをどのようにオフセットすることができますか?

enter image description here

どのように私はイメージが私の実際のタッチ上記40ptについて表示させることができます。 (B)

私は古典的なcoreGraphic UITouchコードを使用しています。..のようなので:

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

    // add the first touch 
    UITouch *touch = [touches anyObject]; 

    previousPoint1 = [touch previousLocationInView:self]; 
    currentPoint = [touch locationInView:self]; 

    //transform = CGAffineTransformTranslate(self.transform, 5.0, 10.0) 

    // init the bezier path 
    self.currentTool = [self toolWithCurrentSettings]; 
    self.currentTool.lineWidth = self.lineWidth; 
    self.currentTool.lineColor = self.lineColor; 
    self.currentTool.lineAlpha = self.lineAlpha; 


     [self.pathArray addObject:self.currentTool]; 
     [self.undoStates addObject:[self.currentTool captureToolState]]; 

     [self.currentTool setInitialPoint:currentPoint]; 
    } 

    // call the delegate 
    if ([self.delegate respondsToSelector:@selector(drawingView:willBeginDrawUsingTool:)]) { 
     [self.delegate drawingView:self willBeginDrawUsingTool:self.currentTool]; 
    } 
} 

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

    // save all the touches in the path 
    UITouch *touch = [touches anyObject]; 

    previousPoint2 = previousPoint1; 
    previousPoint1 = [touch previousLocationInView:self]; 
    currentPoint = [touch locationInView:self]; 

     [self.currentTool moveFromPoint:previousPoint1 toPoint:currentPoint]; 
     [self setNeedsDisplay]; 
    } 

} 

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

    // make sure a point is recorded 
    [self touchesMoved:touches withEvent:event]; 

      CGPoint point = [[touches anyObject] locationInView:self]; 
      [self.currentTool setInitialPoint:point]; 
      self.draggableTextView = ((ACEDrawingDraggableTextTool *)self.currentTool).labelView; 

      [self.pathArray addObject:self.currentTool]; 

      [self finishDrawing]; 

     [self finishDrawing]; 
    } 
} 

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    // make sure a point is recorded 
    [self touchesEnded:touches withEvent:event]; 
} 

任意の助けいただければ幸いです。

答えて

1
previousPoint1 = [touch previousLocationInView:self]; 
currentPoint = [touch locationInView:self]; 
// add these 2 lines below: 
previousPoint1 = CGPointMake(previousPoint1.x, previousPoint1.y+40); 
currentPoint = CGPointMake(currentPoint.x, currentPoint.y+40); 
+1

おかげトン..私はyの使用 - 助けることができる –

+0

がうれしい..私は望んでいた効果を得るために40を、私はあなたが正確に正しい方向に私を指摘感謝しています。 – GeneCode

関連する問題