目标C:使用UIImage来抚摸

我正在尝试为我的画笔应用纹理,但我真的很难确定它是如何完成的。

这是我输出的图像。

我使用了一个UIImage,只是在屏幕上触摸,但是当我快速滑动时,结果是在右侧“W”,而在左侧,结果是当我滑动缓慢。

在这里输入图像说明

我尝试使用CGContextMoveToPointCGContextAddLineToPoint我不知道如何应用纹理。

是否有可能使用UIImage的笔触纹理?

这是我的代码

  UIImage * brushImageTexture = [UIImage imageNamed:@"brushImage.png"]; [brushImagetexture drawAtPoint:CGPointMake(touchCurrentPosition.x, touchVurrentPosition.y) blendMode:blendMode alpha:1.0f]; 

您需要在沿着从前一点到当前点的线的每个点上手动绘制图像。

 CGPoint vector = CGPointMake(currentPosition.x - lastPosition.x, currentPosition.y - lastPosition.y); CGFloat distance = hypotf(vector.x, vector.y); vector.x /= distance; vector.y /= distance; for (CGFloat i = 0; i < distance; i += 1.0f) { CGPoint p = CGPointMake(lastPosition.x + i * vector.x, lastPosition.y + i * vector.y); [brushImageTexture drawAtPoint:p blendMode:blendMode alpha:1.0f]; }