标签: cgcontextdrawpath

如何缩放图形,使用CGContextRef创建

我正在使用CGContextRef绘制线图.我可以放大缩小此图表以清楚地显示线条.

我正在使用此代码.

CGContextRef context=UIGraphicsGetCurrentContext();
CGContextBeginPath(context);

CGMutablePathRef path=CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, lastPointX, lastPointY);
CGPathAddLineToPoint(path, NULL, newPointX, newPointY);

CGContextAddPath(context, path);
CGContextSetLineWidth(context, lineWidth);
CGContextSetStrokeColorWithColor(context, lineColor);
CGContextStrokePath(context);
CGPathRelease(path);

if (isFilling) {
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, newPointX, newPointY);
    CGPathAddLineToPoint(path, NULL, newPointX, self.bounds.size.height);
    CGPathAddLineToPoint(path, NULL, lastPointX, self.bounds.size.height);
    CGPathAddLineToPoint(path, NULL, lastPointX, lastPointY);
    CGPathCloseSubpath(path);

    CGContextAddPath(context, path);
    CGContextSetFillColorWithColor(context, fillingColor);
    CGContextFillPath(context);
    CGPathRelease(path);
}
Run Code Online (Sandbox Code Playgroud)

注意: - 我不想缩放视图.我想重新绘制线条以清楚地显示.

core-graphics objective-c ios cgcontextref cgcontextdrawpath

6
推荐指数
1
解决办法
295
查看次数