MKMapView的黑白覆盖 [英] Black and white overlay for an MKMapView

查看:90
本文介绍了MKMapView的黑白覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 MKMapView 并且正在添加叠加层(MKOverlay)。

I have an MKMapView and am adding an overlay (MKOverlay) to it.

我希望叠加层使地图视图显示为黑色和&白色(即单色)。有没有办法做到这一点?

I would like the overlay to make the map view underneath to appear black & white (i.e. monochrome). Is there any way of doing this?

(我想我可以使叠加半透明的黑色/灰色,但这不是我想要的确切效果。)

(I guess I could make the overlay translucent black/gray, but that's not the exact effect I would like.)



系统详细信息:在Xcode 4.2中开发iOS 5应用程序。

推荐答案

在iOS上可用的最合适的路线是:

The most proper route, which sadly isn't yet available on iOS would be:

您的 MKOverlay 用于创建 MKOverlayView ,它将具有 CALayer ,因为它来自 UIView 。你可以将 CIFilter 作为 compositingFilter 附加到 CALayer s ,它决定了视图如何与背景合成。你可以附上一个 CIColorMonochrome 类型的过滤器。

Your MKOverlay is at some point being used to create an MKOverlayView, which will have a CALayer as it descends from UIView. You can attach CIFilters as compositingFilters to CALayers, which dictate how the view is composited with the background. You could attach a filter of type CIColorMonochrome to that.

因为那个选项不可用,你就是必须跨越一些主要障碍才能为自己做好工作。您可能需要实现自己的自定义 MKOverlayView ,在其 drawView 中使用Apple的 QA1703 获取相关区域中地图视图的像素内容(注意不要结束虽然在无限递归循环中,将它们转换为黑白并将它们显示为您的视图。

Because that option isn't available, you're going to have to leap through some major hurdles to do the work for yourself. You'll probably need to implement your own custom MKOverlayView that in its drawView uses the techniques given in Apple's QA1703 to get the pixel contents of the map view in the relevant area (be careful not to end up in an infinite recursive loop though), transform those into black and white and present them as your view.

这是否值得进一步调查或者您会更高兴替换效果而不是真正深入研究这些东西?

Is that something it's worth investigating further or would you be happier to substitute the effect than to really delve into this stuff?

这篇关于MKMapView的黑白覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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