zoukankan      html  css  js  c++  java
  • IOS之以UIBezierPath绘制饼状图

    1.绘制的饼状图是通过多个扇形拼和而成,绘制一个扇形也是比较简单的,核心代码如下:


    先画一条圆弧,再画半径,接着再画一条圆弧,最后闭合路径;

    1. UIBezierPath*  aPath = [[UIBezierPath alloc] init];  
    2.         [aPath moveToPoint:point2];  
    3.         [aPath addArcWithCenter:_centerPoint radius:_radius startAngle:RADIUS_TO(r.start) endAngle:RADIUS_TO(r.end) clockwise:YES];  
    4.         [aPath addLineToPoint:point];  
    5.         [aPath addArcWithCenter:_centerPoint radius:0.5 * _radius startAngle:RADIUS_TO(r.end) endAngle:RADIUS_TO(r.start) clockwise:NO];  
    6.         [aPath closePath];  


    绘制完成后给整个路径添加填充颜色即可,效果如下:




    2.给饼图添加点击响应事件,实现原理是根据点击点的坐标计算位于饼图的什么区域,以做出相应的响应;


    效果如下:




    最后是工程的源码,http://download.csdn.net/detail/xyybaozhen/8073377点击打开链接

  • 相关阅读:
    vue
    生成数组方式
    绕过CDN查找真实IP方法
    SQL注入WAF绕过
    缓冲区溢出的保护机制
    Redis未授权漏洞
    AFL 漏洞挖掘
    python多线程与多进程
    Java8四大核心接口示例
    @Autowired抱空指针异常解决方案
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/5960235.html
Copyright © 2011-2022 走看看