- (void)drawRect:(CGRect)rect
{
// 1.获取上下文
CGContextRef ctx = UIGraphicsGetCurrentContext(); // 2.绘制图形
/*
// 设置起点
CGContextMoveToPoint(ctx, 10, 10);
// 设置终点
CGContextAddLineToPoint(ctx, 100, 100); // 3.画圆
CGContextAddEllipseInRect(ctx, CGRectMake(50, 50, 50, 50));
*/ // 2.创建路径(一个path就代表一条路径)
// 但凡通过quarzt2d中的带有create/ copy / retain 方法创建出来的值都必须手动的释放
CGMutablePathRef path = CGPathCreateMutable();
// 设置起点
CGPathMoveToPoint(path, NULL, , );
// 设置终点
CGPathAddLineToPoint(path, NULL, , );
// 将路径添加到上下文中
CGContextAddPath(ctx, path); // 3.再创建一条路径用于保存圆
CGMutablePathRef path2 = CGPathCreateMutable();
// 在path中添加画的路径
CGPathAddEllipseInRect(path2, NULL, CGRectMake(, , , ));
CGContextAddPath(ctx, path2); // 3.渲染'
CGContextStrokePath(ctx); // 释放前面创建的两条路径
CGPathRelease(path);
CGPathRelease(path2); // 下面这种方式也可以释放路径 // CFRelease(path);
// CFRelease(path2);
}

最新文章

  1. localstorage 的属性改变问题
  2. python平台跨平台开发
  3. [转载]解析用户生命周期价值:LTV
  4. Changing the type of a property with EF Code First
  5. EntityFramework嵌套查询的五种方法
  6. hdu 4739 状压DP
  7. bzoj1564
  8. 使用Python实现Hadoop MapReduce程序
  9. matplotlib中使用imshow绘制二维图
  10. 【某集训题解】【DAY 2 T3】与非
  11. Oracle-11:联合查询
  12. python之路day05--字典的增删改查,嵌套
  13. [hdu P3085] Nightmare Ⅱ
  14. 实现text-detection-ctpn一路的坎坎坷坷
  15. MongoDB修改与聚合二
  16. Sonatype Nexus Repository Manager修改密码不成功
  17. (4opencv)OpenCV PR 成功的收获和感悟
  18. Android Studio将项目打包成apk
  19. 腾讯云 利用php + apache + mysql 搭建服务器环境
  20. 用js获取当前月份的天数

热门文章

  1. EFK Stack容器部署
  2. [转] 出现( linker command failed with exit code 1)错误总结
  3. 关于给gridSelect控件设置默认值
  4. Python中list作为默认参数的陷阱
  5. luoguP4921 情侣?给我烧了!
  6. RABC(Role-Based Access Control) 基于角色的权限访问控制
  7. css3中的变形(transform)、过渡(transtion)、动画(animation)
  8. crawlspider的源码学习
  9. 配置HEXO
  10. 028 Implement strStr() 实现 strStr()