如何在MKMapview上绘制自定义线? [英] How to draw custom line on MKMapview?
问题描述
我一直在寻找一种绘制自定义线条的方法,但是我唯一能找到的帮助就是如何使用UIColor绘制线条.
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.
我想画一条直线,而不仅仅是用一种颜色.我希望该行的外观可自定义.
I want to draw a straight line but not just with a color. I want the appearance of the line to be customizable.
(所以现在我可以在2点之间画线,但不能画我想要的线)
(So right now I can draw lines between 2 points, but not the line I want)
我要的直线上有45度直线,它是灰色和黑色.
The line I want got straight 45 degree lines on it, and it's grey and black.
有人可以帮忙吗?
这条线看起来像这样,我也在想我可以拉伸该图像,但是如果拉伸它,它将看起来有点奇怪.
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.
推荐答案
听起来像您想要的是 MKOverlayPathView ,您可以设置笔触和填充颜色.
Sound like what your looking for is the MKPolylineView Class. 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.
由于它也是UIView子类,因此您可以通过获取views图层属性并添加渐变,阴影,遮罩等来进一步操纵外观.
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.
您要达到的特定效果吗?
Is there a specific effect that you're trying to achieve?
这篇关于如何在MKMapview上绘制自定义线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!