将倒圆叠加添加到地图视图 [英] Add inverted circle overlay to map view

查看:140
本文介绍了将倒圆叠加添加到地图视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(使用iOS 5和Xcode 4.2。)

我按照这里的说明操作: http:// developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15 并使用 MKCircle MKCircleView 类添加一个圈子覆盖在我的的MKMapView

I've followed the instructions here: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15 and used the MKCircle and MKCircleView classes to add a circle overlay on my MKMapView.

然而,我真正想要的是倒圆形叠加,就像下面草图中的左侧地图(目前我有一个像右边那样的圆形叠加):

However what I actually want is an inverted circle overlay, like the left map in the sketch below (currently I have a circle overlay like the one on the right):

对于倒圆,叠加层应覆盖整个地图 - 除了可见圆圈。

For the inverted circle, the overlay should cover the entire map - apart from the visible circle.

是否有使用MKCircle / MKCircleView类轻松实现此目的?或者我是否需要更深入地定义自定义叠加对象/视图?

Is there an easy way to accomplish this using the MKCircle/MKCircleView classes? Or will I have to go deeper and define a custom overlay object/view?

感谢您的帮助:)

推荐答案

最好的方法是继承 MKMapView 并覆盖 drawRect 方法调用super,然后用你想要的颜色在地图上绘画。
然后每次用户移动时, drawRect 应该通过适当的绘图来回应。

The best way to do it, would be to subclass MKMapView and override the drawRect method call super, then paint over the map with the color you want. Then each time the user moves, drawRect should respond by drawing appropriately.

这篇关于将倒圆叠加添加到地图视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆