简体   繁体   English

如何在MKMapview上绘制自定义线?

[英]How to draw custom line on MKMapview?

I've been searching for a way to draw a custom line, but the only help I can find is how to draw lines with an UIColor. 我一直在寻找一种绘制自定义线条的方法,但是我唯一能找到的帮助就是如何使用UIColor绘制线条。

I want to draw a straight line but not just with a color. 我想画一条直线,而不仅仅是用一种颜色。 I want the appearance of the line to be customizable. 我希望线条的外观可自定义。

(So right now I can draw lines between 2 points, but not the line I want) (所以现在我可以在2点之间画线,但不能画我想要的线)

The line I want got straight 45 degree lines on it, and it's grey and black. 我要的直线上有45度直线,它是灰色和黑色。

Anybody can help? 有人可以帮忙吗?

The line looks like this, I'm also thinking that I could stretch this image, but if I stretch it, it will look kinda weird. 线条看起来像这样,我也在想我可以拉伸此图像,但是如果拉伸它,它将看起来有点奇怪。

在此处输入图片说明

Why don't you add image then? 那为什么不添加图像呢? I'm new developer so I don't know other way to do it. 我是新开发人员,所以我不知道其他方法。 Only OpenGL with texturing, but there is no need to use openGL. 仅具有纹理的OpenGL,但无需使用openGL。 So my suggestion is to add image. 所以我的建议是添加图像。

Sound like what your looking for is the MKPolylineView Class . 听起来像您要找的是MKPolylineView类 You assign it a polyline which contains the points in your line. 您为其分配一条多义线,其中包含您的线中的点。 Since the polyline view is an MKOverlayPathView you can set the stroke and fill colors. 由于折线视图是MKOverlayPathView ,因此可以设置笔触和填充颜色。

Since it's also a UIView subclass you can manipulate the appearance even further by grabing the views layer property and adding gradients, shadows, masks, etc. 由于它也是UIView子类,因此您可以通过获取views图层属性并添加渐变,阴影,蒙版等来进一步操纵外观。

Is there a specific effect that you're trying to achieve? 您是否想达到特定的效果?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM