IOS Quarzt2D 手动的释放
2024-09-04 12:02:00
- (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);
}
最新文章
- localstorage 的属性改变问题
- python平台跨平台开发
- [转载]解析用户生命周期价值:LTV
- Changing the type of a property with EF Code First
- EntityFramework嵌套查询的五种方法
- hdu 4739 状压DP
- bzoj1564
- 使用Python实现Hadoop MapReduce程序
- matplotlib中使用imshow绘制二维图
- 【某集训题解】【DAY 2 T3】与非
- Oracle-11:联合查询
- python之路day05--字典的增删改查,嵌套
- [hdu P3085] Nightmare Ⅱ
- 实现text-detection-ctpn一路的坎坎坷坷
- MongoDB修改与聚合二
- Sonatype Nexus Repository Manager修改密码不成功
- (4opencv)OpenCV PR 成功的收获和感悟
- Android Studio将项目打包成apk
- 腾讯云 利用php + apache + mysql 搭建服务器环境
- 用js获取当前月份的天数
热门文章
- EFK Stack容器部署
- [转] 出现( linker command failed with exit code 1)错误总结
- 关于给gridSelect控件设置默认值
- Python中list作为默认参数的陷阱
- luoguP4921 情侣?给我烧了!
- RABC(Role-Based Access Control) 基于角色的权限访问控制
- css3中的变形(transform)、过渡(transtion)、动画(animation)
- crawlspider的源码学习
- 配置HEXO
- 028 Implement strStr() 实现 strStr()