iOS 折线图,柱状图

在网上看了许多大家写的折线图,柱状图,有两种

  • 如果只是简单的运用,可以自己用动画写一个
    github地址

在网上看了许多大家写的折线图,柱状图,有两种
效果图
要点有:
UIBezierPath用于定义一个直线/曲线组合而成的路径,并且可以在自定义视图中渲染该路径。

1 .

+ (instancetype)bezierPath;

初始化一个UIBezierPath对象。

2 .路径操作函数

- (void)moveToPoint:(CGPoint)point;  
将当前点移动到指定的位置。

UIBezierPath *bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint:CGPointMake(100, 300)];
  • -(void)addLineToPoint:(CGPoint)point;在路径中增加一条直线(起点+终点=一条直线
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint:CGPointMake(100,300)];
[bezierPath addLineToPoint:CGPointMake(150, 150)];

这样就可以划出那些直线

使用CAShaperLayer也可以绘图,优点在于:GPU执行
可以看看这位大神的随笔https://www.cnblogs.com/zhouxihi/p/6273796.html,更加方便简洁

  • 网上也有很多优秀的第三方库,运用的效果更加自如,比如,百度开发的E-charts等等
    要点有:
    UIBezierPath用于定义一个直线/曲线组合而成的路径,并且可以在自定义视图中渲染该路径。

1 .

+ (instancetype)bezierPath;

初始化一个UIBezierPath对象。

2 .路径操作函数

- (void)moveToPoint:(CGPoint)point;  
将当前点移动到指定的位置。

UIBezierPath *bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint:CGPointMake(100, 300)];
  • -(void)addLineToPoint:(CGPoint)point;在路径中增加一条直线(起点+终点=一条直线
UIBezierPath *bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint:CGPointMake(100,300)];
[bezierPath addLineToPoint:CGPointMake(150, 150)];

这样就可以划出那些直线

使用CAShaperLayer也可以绘图,优点在于:GPU执行
可以看看这位大神的随笔https://www.cnblogs.com/zhouxihi/p/6273796.html,更加方便简洁

  • 网上也有很多优秀的第三方库,运用的效果更加自如,比如,百度开发的E-charts等等
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值