Ios 使用kCGBlendModeMultiply的MapKit覆盖
我对MKMapView有一个非常具体的用例。我生成了大量的MKPolygons(大约15000个)并在叠加上渲染它们。要提高性能,请执行以下步骤:Ios 使用kCGBlendModeMultiply的MapKit覆盖,ios,mkmapview,core-graphics,mapkit,mkoverlay,Ios,Mkmapview,Core Graphics,Mapkit,Mkoverlay,我对MKMapView有一个非常具体的用例。我生成了大量的MKPolygons(大约15000个)并在叠加上渲染它们。要提高性能,请执行以下步骤: 在地图视图中添加一个覆盖图,其大小与整个世界相同 在-(void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)上下文中,我检查每个多边形是否包含在当前mapRect中(因为MapKit将贴图分为平铺,并在不同线程上并行渲
-(void)drawMapRect:(mkmapret)mapret zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
{
[super-drawMapRect:mapRect-zoomScale:zoomScale-inContext:context];
CGContextSaveGState(上下文);
CGContextSetBlendMode(上下文,kCGBlendModeMultiply);
NSArray*polygons=((IndexPolygonsMapOverlay*)self.overlay.多边形;
@自动释放池{
用于(MYMKPolygonSubClass*多边形中的多边形){
如果(!MKMapRectIntersectsRect(poly.boundingMapRect,mapRect)){
继续;
}
如果(!poly.color)继续;
CGContextSaveGState(上下文);
CGContextSetFillColorWithColor(上下文,poly.color.CGColor);
CGContextMoveToPoint(上下文,(CGFloat)多边形点[0].x,(CGFloat)多边形点[0].y);
对于(int idx=1;idx
有没有人对多重混合模式有过类似的体验,特别是在MKMapView上使用时
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
{
[super drawMapRect:mapRect zoomScale:zoomScale inContext:context];
CGContextSaveGState(context);
CGContextSetBlendMode(context, kCGBlendModeMultiply);
NSArray *polygons = ((IndexPolygonsMapOverlay *) self.overlay).polygons;
@autoreleasepool {
for (MYMKPolygonSubClass *poly in polygons) {
if (!MKMapRectIntersectsRect(poly.boundingMapRect, mapRect)) {
continue;
}
if (!poly.color) continue;
CGContextSaveGState(context);
CGContextSetFillColorWithColor(context, poly.color.CGColor);
CGContextMoveToPoint(context, (CGFloat) poly.points[0].x, (CGFloat) poly.points[0].y);
for (int idx = 1; idx < poly.pointCount; idx ++) {
CGContextAddLineToPoint(context, (CGFloat) poly.points[idx].x, (CGFloat) poly.points[idx].y);
}
CGContextClosePath(context);
CGContextDrawPath(context, kCGPathFill);
CGContextRestoreGState(context);
}
}
CGContextRestoreGState(context);
}