gpt4 book ai didi

ios - 如何使 UITouches 偏移?

转载 作者:行者123 更新时间:2023-11-29 00:34:10 32 4
gpt4 key购买 nike

在下图中,我进行绘制,结果位于 A 点,就在我手指接触的地方。

enter image description here

如何使图像显示在实际触摸上方约 40pt。 (二)

我正在使用经典的 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];
}

最佳答案

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);

关于ios - 如何使 UITouches 偏移?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41029403/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com