【发布时间】:2012-01-22 09:50:03
【问题描述】:
我正在使用 Core Graphics 绘制一条宽度为 4 像素的任意线,现在我希望这条线具有另一种颜色的 1 像素轮廓。我看不到任何可以实现“开箱即用”的 CG 功能,但我正在寻找有关如何完成的建议。这是我现有的代码:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 4.0);
CGPoint curPoint = [(NSValue*)[points objectAtIndex:0] CGPointValue];
CGContextMoveToPoint(context, curPoint.x, curPoint.y);
for( int i = 1; i < [points count]; i++ ) {
curPoint = [(NSValue*)[points objectAtIndex:i] CGPointValue];
CGContextAddLineToPoint(context, curPoint.x, curPoint.y);
CGContextStrokePath(context);
CGContextMoveToPoint(context, curPoint.x, curPoint.y);
}
这会产生单行。我想生成一条 4px 线,其中 1px 线突出显示 4px 线,如下所示:
【问题讨论】:
标签: iphone cocoa-touch core-graphics