ios - 如何在 map 上的 iOS 7 中填充外部覆盖圈

标签 ios ios7 mapkit mkoverlay

我需要与 iOS7 中的提醒应用程序一样在 map 上围绕圆圈填充的空间。我认为需要使用 applyFillPropertiesToContext:atZoomScalefillPath:inContext: 方法。

iOS 7 Reminders

最佳答案

我解决了我的问题:

- (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];
}

关于ios - 如何在 map 上的 iOS 7 中填充外部覆盖圈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19984755/

相关文章:

ios - 如何防止启动图像在 iOS 7 的 Web 应用程序中垂直拉伸(stretch)?

ios - UITableView 在开始/结束更新调用调整高度后自动滚动到顶部

ios - didSelect for MKAnnotationView 未触发

ios - UINavigationBar下的自定义UISearchBar错误的色调

objective-c - 关于在 iOS 中旋转 map

objective-c - 使用 CLLocation 对象作为字典中的键

iOS通知观察者单元测试( objective-c )

ios - 调度队列和异步 RNCryptor

ios - ImageView.contentMode 不适用于 Collection View

ios - 使用 Core Data 的 transient 属性作为缓存