How to fill outside overlay circle in iOS 7 on map

我的未来我决定 提交于 2019-12-30 05:17:05

问题


I need the same filled space around circle on the map as in Reminders app in iOS7. I think need to use the method applyFillPropertiesToContext:atZoomScale or fillPath:inContext:.


回答1:


I solved my problem:

- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context
{
    // Fill full map rect with some color.
    CGRect rect = [self rectForMapRect:mapRect];
    CGContextSaveGState(context);
    CGContextAddRect(context, rect);
    CGContextSetFillColorWithColor(context, [UIColor colorWithWhite:0.0 alpha:0.4f].CGColor);
    CGContextFillRect(context, rect);
    CGContextRestoreGState(context);

    // Clip rounded hole.
    CGContextSaveGState(context);
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextSetBlendMode(context, kCGBlendModeClear);
    CGContextFillEllipseInRect(context, [self rectForMapRect:[self.overlay boundingMapRect]]);
    CGContextRestoreGState(context);

    // Draw circle
    [super drawMapRect:mapRect zoomScale:zoomScale inContext:context];
}


来源:https://stackoverflow.com/questions/19984755/how-to-fill-outside-overlay-circle-in-ios-7-on-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!