【发布时间】:2011-01-30 19:23:33
【问题描述】:
我正在使用 route-me 的框架来处理位置。 在此代码中,两个标记(点)之间的路径将绘制为一条线。
我的问题:“如果我想在线的中间(或顶部)添加一个箭头,我应该添加什么代码,以便它指向方向”
谢谢
- (void)drawInContext:(CGContextRef)theContext
{
renderedScale = [contents metersPerPixel];
float scale = 1.0f / [contents metersPerPixel];
float scaledLineWidth = lineWidth;
if(!scaleLineWidth) {
scaledLineWidth *= renderedScale;
}
//NSLog(@"line width = %f, content scale = %f", scaledLineWidth, renderedScale);
CGContextScaleCTM(theContext, scale, scale);
CGContextBeginPath(theContext);
CGContextAddPath(theContext, path);
CGContextSetLineWidth(theContext, scaledLineWidth);
CGContextSetStrokeColorWithColor(theContext, [lineColor CGColor]);
CGContextSetFillColorWithColor(theContext, [fillColor CGColor]);
// according to Apple's documentation, DrawPath closes the path if it's a filled style, so a call to ClosePath isn't necessary
CGContextDrawPath(theContext, drawingMode);
}
【问题讨论】:
-
我不久前得到了codeguru.com/cpp/g-m/gdi/article.php/c3683 无论如何谢谢你的答案 Greetz
-
Pete,您最好还是将答案标记为已接受,或者将您的答案作为答案发布然后接受。
-
@Pete 你为什么不标记正确的答案(我的意思是 Friedhelm 的)?
标签: iphone core-graphics quartz-2d cgcontext