如何沿 CGMutablePathRef 绘制自定义 uiimage?我可以从 CGMutablePathRef 获得点,但它没有给出创建路径的平滑点。
我想知道我是否可以提取所有这些以及创建平滑路径的那个。
我使用了 CGPathApply 但我只得到了控制点,当我绘制我的图像时它不会像原始的 CGmutablePathRef 那样保持平滑
void pathFunction(void *info, const CGPathElement *element){
if (element->type == kCGPathElementAddQuadCurveToPoint)
{
CGPoint firstPoint = element->points[1];
CGPoint lastPoint = element->points[0];
UIImage *tex = [UIImage imageNamed:@"myimage.png"];
CGPoint vector = CGPointMake(lastPoint.x - firstPoint.x, lastPoint.y - firstPoint.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(firstPoint.x + i * vector.x, firstPoint.y + i * vector.y);
[tex drawAtPoint:p blendMode:kCGBlendModeNormal alpha:1.0f];
}
}
}