我正在使用iOS 4上的iPhone上的mapkit。 我正在使用自定义覆盖层和自定义覆盖层视图,在地图上绘制形状。 目前,这些形状只是矩形,但我计划使用更复杂的形状。这就是为什么我不使用MKPolygon覆盖类型的原因。 以下是我的覆盖层视图绘制方法的代码:
-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
{
// Clip context to bounding rectangle
MKMapRect boundingMapRect = [[self overlay] boundingMapRect];
CGRect boundingRect = [self rectForMapRect:boundingMapRect];
CGContextAddRect(context, boundingRect);
CGContextClip(context);
// Define shape
CGRect shapeRect = CGRectMake(0.5f, 0.5f, boundingRect.size.width - 1.0f, boundingRect.size.height - 1.0f);
// Fill
CGContextSetRGBFillColor(context, 0.5f, 0.5f, 0.5f, 0.5f);
CGContextFillRect(context, shapeRect);
// Stroke
CGContextSetRGBStrokeColor(context, 0, 0, 0, 0.75f);
CGContextSetLineWidth(context, 1.0f);
CGContextStrokeRect(context, shapeRect);
}
问题在于矩形被正确填充(因此其边界矩形的设置似乎是正确的),但它们没有被描边。
有人能帮忙吗?
谢谢!
CGRectMake
创建矩形)。 - DarkDust