iOS开发的动态曲线图绘制
2017-07-20 本文已影响363人
hmj1993
最近项目中需要用到曲线图,虽然有很多demo,但还是想自己写个,毕竟也不难,当然效果不如网上那些大神的好看~毕竟水平有限,但是也足够我应付项目需求了嘿嘿(主要还是闲的,哈哈)
首先效果如图:

1.首先自定义一个view,我定义了这些属性
(忽略我蹩脚的起名)


2.开始画图 首先根据x坐标的个数画出表格中的竖线及坐标刻度

依葫芦画瓢得到众横线

接着根据实际值在表格中划出红点及实际坐标值

其中以下是两个懒加载

自定义的初始化方法:

动态连接各个点,我让这个行为在️秒内执行完

大功告成,直接就可以调用啦
