0
UITouchポイントをオフセットすることはできますか?私は以下のタッチメソッドを使用しています。いくつかの番号でタッチポイントをオフセットして、タッチが開始されて描画される場所をユーザーが確認するようにしたいと思います。私が線の中に描こうとしているなら、ペンや鉛筆のように指先の上を見たい。助けを歓迎します。Objective Cでタッチポイントをオフセットできますか?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// add the first touch
UITouch *touch = [touches anyObject];
previousPoint = [touch previousLocationInView:self];
currentPoint = [touch locationInView:self];
// init the bezier path
self.currentTool = [self toolWithCurrentSettings];
self.currentTool.lineWidth = self.lineWidth;
self.currentTool.lineColor = self.lineColor;
self.currentTool.lineAlpha = self.lineAlpha;
[self.currentTool setInitialPoint:currentPoint];
...
- (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];
//currentPoint.y += 40;
CGRect bounds = [(DrawingPenTool*)self.currentTool addPathPreviousPoint:previousPoint2 withPreviousPoint:previousPoint1 withCurrentPoint:currentPoint];
CGRect drawBox = bounds;
drawBox.origin.x -= self.lineWidth * 2.0;
drawBox.origin.y -= self.lineWidth * 2.0;
drawBox.size.width += self.lineWidth * 4.0;
drawBox.size.height += self.lineWidth * 4.0;
[self setNeedsDisplayInRect:drawBox];
[self.currentTool moveFromPoint:previousPoint1 toPoint:currentPoint];
[self setNeedsDisplay];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesMoved:touches withEvent:event];
CGPoint point = [[touches anyObject] locationInView:self];
[self.currentTool setInitialPoint:point];
}
}
詳細については、WWDC 2015または2016の「タッチ」ビデオをご覧ください。アプリの描画は、これらの動画のターゲットオーディエンスです。 – matt
ありがとう@matt。 Appleの鉛筆を使用していない場合でも、私はestimatedPropertiesを使用することができますかビデオを見るか2 –
ですか? –