目标C:使用UIImage进行描边操作

Seo*_*gHo 2 iphone core-graphics objective-c ipad ios

我正在尝试为我的画笔应用纹理,但我真的很难弄清楚它是如何完成的.

这是我输出的图像.

我使用了一个UIImage,只是按照屏幕上的触摸,但当我快速滑动时,结果在右侧"W",而在左侧,这是我慢慢滑动的结果.

在此输入图像描述

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

是否可以使用UIImage作为笔触纹理?

这是我的代码

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

rob*_*off 5

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

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];
}
Run Code Online (Sandbox Code Playgroud)