【发布时间】:2015-07-15 11:00:47
【问题描述】:
我正在使用 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);
}
注意:- 我不想缩放视图。我想重新绘制线条以清晰显示。
【问题讨论】:
标签: ios objective-c core-graphics cgcontextref cgcontextdrawpath