在网上看了许多大家写的折线图,柱状图,有两种
- 如果只是简单的运用,可以自己用动画写一个
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等等