0
是否可以抵消UITouch點?我正在使用下面顯示的觸摸方法。我想通過某個數字來抵消觸摸點,以便用戶能夠看到觸摸開始和畫出的位置。如果我試圖畫線,我想看到我的指尖,就像我們用鋼筆和鉛筆做的一樣。任何幫助歡迎。我可以偏移目標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。關閉以觀看視頻或2 –
即使我未使用Apple Pencil,也可以使用estimatedProperties嗎? –