百度地图自定义大头针&&大头针

发布于 2021-12-22 21:03:14 字数 1900 浏览 899 评论 0

# YWLJMapView
利用百度地图实现自定义大头针和气泡

###自定义大头针
----------------------------------------------------------
效果图:---->没错就是链家
![001.png](http://upload-images.jianshu.io/upload_images/1488651-acd22675f5000f79.png?imageMogr2/auto-orient/strip|imageView2/2/w/1240)

----------------------------------------------------------

```
//背景色
CGRect rect = _contentView.bounds;
//创建Path -->类似于对话框气泡路径实现
CGMutablePathRef layerpath = CGPathCreateMutable();
CGPathMoveToPoint(layerpath, NULL, 0, 0);
CGPathAddLineToPoint(layerpath, NULL, CGRectGetMaxX(rect), 0);
CGPathAddLineToPoint(layerpath, NULL, CGRectGetMaxX(rect), CGRectGetMaxY(rect));

CGPathAddLineToPoint(layerpath, NULL, 45, CGRectGetMaxY(rect));
CGPathAddLineToPoint(layerpath, NULL, 37.5, CGRectGetMaxY(rect)+5);
CGPathAddLineToPoint(layerpath, NULL, 30, CGRectGetMaxY(rect));
CGPathAddLineToPoint(layerpath, NULL, 0, CGRectGetMaxY(rect));
CAShapeLayer *shapelayer=[CAShapeLayer layer];
UIBezierPath *path=[ UIBezierPath bezierPathWithCGPath:layerpath];
shapelayer.path=path.CGPath;
shapelayer.fillColor=[ UIColor colorWithRed:83/255.0 green:180/255.0 blue:119/255.0 alpha:1.0].CGColor;
shapelayer.cornerRadius=5;
[_contentView.layer addSublayer:shapelayer];
```
----------------------------------------------------------
demo传送门[这里](https://github.com/Mr-yuwei/YWLJMapView)
注意下载的demo需要自己重新编辑一下,因为pod文件太大,上传有限制,欢迎到git上下载。

下载地址:http://www.wenjiangs.com/wp-content/uploads/2021/docimg35/b367a4d8364ae408822ec047db214ab3.zip

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文