用石英绘制航向角视图
我只是想像地图应用程序一样在 MKMapView 上绘制标题角度视图,当然我可以使用 Photoshop 或任何必要的程序来做到这一点。但我不需要考虑视网膜显示或屏幕差异。是否可以用石英或任何相关的内置库绘制这个形状以及如何绘制?
提前致谢。
I just wanted to draw heading angle view on MKMapView like Maps app, Of course I can do that with photoshop or any necessary program. But I don't need to consider retina display or screen differences. Is it possible to draw this shape with quartz or any related built in library and how ?
thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以 ;)
为此,您需要实现此方法:
在此方法中,您必须仅针对注释的用户位置情况创建 MKAnnotationView 子类的实例,例如:
注意 KVO 语句,让您的自定义 MKAnnotationView 值已更改
在你的 MKAnnotationView 子类中,你需要重写drawRect;例如,
这绘制了一个带有紫色线的红色标线,显示标题(在我的示例中,课程被窃听,因为我在三角学方面很弱;)但它绘制了:)
您当然需要处理 KVO 通知,例如
:
-setNeedsDisplay
将触发重绘。确保您的自定义视图具有非零矩形框架,并且不要为其设置图像。
You can ;)
To do so, you need to implement this method :
In this one you will have to create a instance of a subclass of MKAnnotationView only for the user location case of annotation like:
Note the KVO statement to let your custom MKAnnotationView that the value has changed
in your MKAnnotationView subclass you need to override drawRect; like that for example
This draws a red reticle with a purple line showing the heading (in my sample the course is bugged because i am just weak in trigonometry ;) but it draws :)
You of course need to handle the KVO notification like:
the
-setNeedsDisplay
will trigger the redraw.Make sure that you custom view has a non-zero rect frame, and do NOT set an image to it.
以前没有使用过 MKMapView,但您也许可以对其进行子类化,并在您的 drawRect: 方法中首先绘制超类,然后使用标准 CG 绘制方法在其顶部绘制您的航向角度。
Having not used MKMapView before, but you might be able to subclass it and in your drawRect: method first draw the superclass and then use standard CG drawing methods to draw your heading angle on top of it.