iphone - MKOverlayView 中的裁剪 :drawMapRect

标签 iphone objective-c ios mapkit

在我的 MKOverlayView 中,我在绘制传递给 drawMapRect:mapRect:zoomScale:inContextMKMapRect 之外的区域时遇到问题派生类。我试图为集合中的每个坐标绘制一个三角形,当坐标靠近 MKMapRect 的边缘时会出现问题。有关问题的示例,请参见下图。

alt text

在图像中,浅红色框表示每次调用 drawMapRect 时呈现的 MKMapRect。问题在红色圆圈中说明,如您所见,只有三角形的一部分被渲染。我假设它被剪裁到 MKMapRect,尽管 MKOverlayView:drawMapRect 的文档让我认为这不应该发生。

来自文档:

You should also not make assumptions that the view’s frame matches the bounding rectangle of the overlay. The view’s frame is actually bigger than the bounding rectangle to allow you to draw lines for things like roads that might be located directly on the border of that rectangle.

我目前的解决方案是多次绘制对象,如果它们位于比给定 drawMapRect 的 maprect 稍大的 maprect 中,但这会导致我绘制一些超出需要的东西。

有谁知道在 drawMapRect 中增加裁剪区域大小的方法,所以这不是问题?也欢迎任何其他建议。

最佳答案

我最终向传入 drawMapRect:mapRect:zoomScale:inContext 的矩形添加了一个缓冲区,并使用它来确定要绘制的对象。这会导致绘制的对象比需要的多,但不会太多。

关于iphone - MKOverlayView 中的裁剪 :drawMapRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3866070/

相关文章:

ios - 尝试更改帧大小的 UIView 动画在 iOS 8 中不起作用,但在 iOS 7 中不起作用

iphone - 关于iOS绘图的问题

ios - XCode - 启用推送通知需要已添加的 Apple ID

ios - 在 objective-c 中注册设置代码

objective-c - 为什么垃圾收集不适用于线程?

ios - 如何在 iOS 中升级(而不是更新)应用程序?

iphone - parent 的所有 child 的 NSFetchRequest

iOS 7 presentViewController 显示黑屏和 SIGABRT

objective-c - 通过 AVAssetReader 读取样本

ios - 如何在 Core Data 对象中存储 Twitter ID