IOS之以UIBezierPath绘制饼状图
2014-10-27 10:07
351 查看
1.绘制的饼状图是通过多个扇形拼和而成,绘制一个扇形也是比较简单的,核心代码如下:
先画一条圆弧,再画半径,接着再画一条圆弧,最后闭合路径;
UIBezierPath* aPath = [[UIBezierPath alloc] init];
[aPath moveToPoint:point2];
[aPath addArcWithCenter:_centerPoint radius:_radius startAngle:RADIUS_TO(r.start) endAngle:RADIUS_TO(r.end) clockwise:YES];
[aPath addLineToPoint:point];
[aPath addArcWithCenter:_centerPoint radius:0.5 * _radius startAngle:RADIUS_TO(r.end) endAngle:RADIUS_TO(r.start) clockwise:NO];
[aPath closePath];
绘制完成后给整个路径添加填充颜色即可,效果如下:
2.给饼图添加点击响应事件,实现原理是根据点击点的坐标计算位于饼图的什么区域,以做出相应的响应;
效果如下:
最后是工程的源码,http://download.csdn.net/detail/xyybaozhen/8073377点击打开链接
先画一条圆弧,再画半径,接着再画一条圆弧,最后闭合路径;
UIBezierPath* aPath = [[UIBezierPath alloc] init];
[aPath moveToPoint:point2];
[aPath addArcWithCenter:_centerPoint radius:_radius startAngle:RADIUS_TO(r.start) endAngle:RADIUS_TO(r.end) clockwise:YES];
[aPath addLineToPoint:point];
[aPath addArcWithCenter:_centerPoint radius:0.5 * _radius startAngle:RADIUS_TO(r.end) endAngle:RADIUS_TO(r.start) clockwise:NO];
[aPath closePath];
绘制完成后给整个路径添加填充颜色即可,效果如下:
2.给饼图添加点击响应事件,实现原理是根据点击点的坐标计算位于饼图的什么区域,以做出相应的响应;
效果如下:
最后是工程的源码,http://download.csdn.net/detail/xyybaozhen/8073377点击打开链接
相关文章推荐
- IOS之以UIBezierPath绘制饼状图
- iOS 简单的使用UIBezierPath绘制
- iOS 使用UIBezierPath与CABasicAnimation绘制图形
- iOS 使用UIBezierPath绘制圆型, 并且根据半径, 角度, 长度在圆外任意一点绘制线段, 通常用于饼状图的文字说明
- iOS 雷达图的绘制 贝塞尔曲线的使用UIBezierPath
- iOS 雷达图的绘制 贝塞尔曲线的使用UIBezierPath
- iOS开发的2D绘制--CoreGraphics的简单使用四(UIBezierPath)
- iOS 雷达图的绘制 贝塞尔曲线的使用UIBezierPath
- iOS使用Charts框架绘制饼状图
- iOS 雷达图的绘制 贝塞尔曲线的使用UIBezierPath
- iOS-UIBezierPath绘制基本图形
- iOS使用Charts框架绘制—饼状图
- iOS开发示例————使用CAShapeLayer&UIBezierPath绘制数据饼图
- iOS 使用UIBezierPath, CAShapeLayer, CABasicAnimation动态绘制折线
- 利用贝塞尔曲线绘制(UIBezierPath)自定义iOS动态速度表,可以自定义刻度,刻度值,进度条样式
- iOS 简单的使用UIBezierPath绘制
- iOS基本图形绘制--UIBezierPath
- iOS使用Charts框架绘制—饼状图
- iOS 使用UIBezierPath 绘制图形
- iOS 雷达图的绘制 贝塞尔曲线的使用UIBezierPath