Quartz2D简单绘制之饼状图

View Code
// 画扇形
// 红色部分
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGFloat components[] = { 1.0f, 0.0f, 0.0f, 1.0f};
CGContextSetFillColor(contextRef, components);
CGContextMoveToPoint(contextRef, 150.0f, 150.0f);
CGContextAddArc(contextRef, 150.0f, 150.0f, 100.0f, 0 * (M_PI / 180.0f), 120 * (M_PI / 180.0f), 0);
CGContextFillPath(contextRef);
// 绿色部分
CGFloat blueComponents[] = { 0.0f, 1.0f, 0.0f, 1.0f};
CGContextSetFillColor(contextRef, blueComponents);
CGContextMoveToPoint(contextRef, 150.0f, 150.0f);
CGContextAddArc(contextRef, 150.0f, 150.0f, 100.0f, 120 * (M_PI / 180.0f), 200 * (M_PI / 180.0f), 0);
CGContextFillPath(contextRef);



相关文章:

  • 2021-04-05
  • 2021-04-14
  • 2021-11-20
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-25
  • 2021-09-13
  • 2021-12-31
  • 2021-05-17
  • 2022-01-20
  • 2021-12-06
  • 2022-01-23
相关资源
相似解决方案