UIBezierPath的使用(持续更新)
UIBezierPath的使用

1. 使用UIBezierPath绘制多边形
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPath]; // 设定起始点
[aPath moveToPoint:CGPointMake(0.0f, 0.0f)]; // 添加点
[aPath addLineToPoint:CGPointMake(100.0f, 100.0f)];
[aPath addLineToPoint:CGPointMake(.f, .f)]; // 闭合path
[aPath closePath];

2. 使用UIBezierPath绘制圆形
// 将常数转换为度数
#define DEGREES(degrees) ((3.14159265359f * degrees)/ 180.f) // 获取path
UIBezierPath *aPath = \
[UIBezierPath bezierPathWithArcCenter:CGPointMake(, ) // 圆的中心
radius:.f // 圆的半径
startAngle:DEGREES() // 起始点
endAngle:DEGREES() // 结束点
clockwise:YES]; // 顺时针

3. 使用UIBezierPath绘制矩形
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPathWithRect:CGRectMake(, , , )];

4. 使用UIBezierPath绘制椭圆
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(, , , )];

5. 使用UIBezierPath绘制圆角矩形
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(, , , )
cornerRadius:.f];

6. 使用UIBezierPath绘制带部分圆角的矩形
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(, , , )
byRoundingCorners:UIRectCornerTopLeft
cornerRadii:CGSizeMake(, )];

7. 使用UIBezierPath绘制不规则曲线1
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPath];
// 设定起始点
[aPath moveToPoint:CGPointMake(0.0f, 0.0f)];
// 添加一个不规则点
[aPath addCurveToPoint:CGPointMake(100.f, 100.f)
controlPoint1:CGPointMake(50.f, 0.f) // 开始点
controlPoint2:CGPointMake(0.f, 50.f)]; // 结束点
// 添加一个点
[aPath addLineToPoint:CGPointMake(0.0f, 100.f)];
// 闭合path
[aPath closePath];


8. 使用UIBezierPath绘制不规则曲线2
// 获取path
UIBezierPath *aPath = [UIBezierPath bezierPath]; // 设定起始点
[aPath moveToPoint:CGPointMake(0.0f, 0.0f)]; // 添加一个不规则点
[aPath addQuadCurveToPoint:CGPointMake(.f, .f)
controlPoint:CGPointMake(.f, .f)]; // 控制点 // 添加一个点
[aPath addLineToPoint:CGPointMake(0.0f, .f)]; // 闭合path
[aPath closePath];


9. 使用path与CAShapeLayer配合制作mask遮罩效果(path闭环里面的填充区域就是作为遮罩使用的)
// 创建一个view
UIView *showView = [[UIView alloc] initWithFrame:CGRectMake(, , , )];
showView.backgroundColor = [UIColor greenColor];
showView.layer.contents = (__bridge id)([UIImage imageNamed:@""].CGImage); // 创建一个椭圆的path
UIBezierPath *aPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(, , , )]; // 创建一个CAShapeLayer并获取椭圆的path
CAShapeLayer *layer = [CAShapeLayer layer];
layer.path = aPath.CGPath; // 把这个CAShapeLayer添加为mask
showView.layer.mask = layer;


UIBezierPath calls
UIBezierPath的使用(持续更新)的更多相关文章
- 神技!微信小程序(应用号)抢先入门教程(附最新案例DEMO-豆瓣电影)持续更新
微信小程序 Demo(豆瓣电影) 由于时间的关系,没有办法写一个完整的说明,后续配合一些视频资料,请持续关注 官方文档:https://mp.weixin.qq.com/debug/wxadoc/de ...
- iOS系列教程 目录 (持续更新...)
前言: 听说搞iOS的都是高富帅,身边妹子无数.咱也来玩玩.哈哈. 本篇所有内容使用的是XCode工具.Swift语言进行开发. 我现在也是学习阶段,每一篇内容都是经过自己实际编写完一遍之后,发现 ...
- ASP.NET MVC 5 系列 学习笔记 目录 (持续更新...)
前言: 记得当初培训的时候,学习的还是ASP.NET,现在回想一下,图片水印.统计人数.过滤器....HttpHandler是多么的经典! 不过后来接触到了MVC,便立马爱上了它.Model-View ...
- git常用命令(持续更新中)
git常用命令(持续更新中) 本地仓库操作git int 初始化本地仓库git add . ...
- iOS开发系列文章(持续更新……)
iOS开发系列的文章,内容循序渐进,包含C语言.ObjC.iOS开发以及日后要写的游戏开发和Swift编程几部分内容.文章会持续更新,希望大家多多关注,如果文章对你有帮助请点赞支持,多谢! 为了方便大 ...
- 基于android studio的快捷开发(将持续更新)
对于Android studio作为谷歌公司的亲儿子,自然有它的好用的地方,特别是gradle方式和快捷提示方式真的很棒.下面是我在实际开发中一些比较喜欢用的快速开发快捷键,对于基本的那些就不多说了. ...
- 总结js常用函数和常用技巧(持续更新)
学习和工作的过程中总结的干货,包括常用函数.常用js技巧.常用正则表达式.git笔记等.为刚接触前端的童鞋们提供一个简单的查询的途径,也以此来缅怀我的前端学习之路. PS:此文档,我会持续更新. Aj ...
- 我的敏捷、需求分析、UML、软件设计电子书 - 下载(持续更新中)
我将所有我的电子书汇总在一起,方便大家下载!(持续更新) 文档保存在我的网站——软件知识原创基地上(www.umlonline.org),请放心下载. 1)软件设计是怎样炼成的?(2014-4-1 发 ...
- React Native之坑总结(持续更新)
React Native之坑总结(持续更新) Genymotion安装与启动 之前我用的是蓝叠(BlueStack)模拟器,跑RN程序也遇到了一些问题,都通过搜索引擎解决了,不过没有记录. 但是Blu ...
随机推荐
- ueditor 编辑器上传到服务器后图片上传不能正常使用
网站集成ueditor编辑器后在本地能正常使用,上传到服务器上后,图片上传功能提示:后端配置项没有正常加载,上传插件不能正常使用.且单个图片上传图标是灰色的不能点击. 相信遇到这个问题的同学是很多的吧 ...
- ConcurrentMap
ConcurrentMap接口下有两个重要的实现: ConcurrentHashMap ConcurrentSkipListMap(支持并发排序功能,弥补ConcurrentHashMap) Conc ...
- [你必须知道的.NET]第十九回:对象创建始末(下)
本文将介绍以下内容: 对象的创建过程 内存分配分析 内存布局研究 接上回[第十八回:对象创建始末(上)],继续对对象创建话题的讨论>>> 2.2 托管堆的内存分配机制 引用类型的实例 ...
- qrcode 生成二维码
qrcode 生成二维码 Demo: https://www.hgnulb.cn/freedom/qrcode/qrcode.html qrcodeGithub 地址: https://github. ...
- oracle 子查询和组合函数
oracle 子查询和组合函数 --查询与"SCOTT"在同一个部门的员工 select empno,ename,deptno from emp where deptno in ( ...
- Java 单例模式的七种写法
Java 单例模式的七种写法 第一种(懒汉,线程不安全) public class Singleton { private static Singleton instance; private Sin ...
- 表A中一条记录的两个字段都对应于表B的同一个字段 如何查询?SQL, thinkphp[5]
表 A=approval_order, B=admin, 表A中technician_username, salesman_username 都是id号,中文名保存在admin表的nickname ...
- XPath中的text()和string()区别(转)
原文地址 : http://blog.csdn.net/jiangchao858/article/details/63314426 本质区别 text()是一个node test,而string()是 ...
- [BZOJ5109][LOJ #6252][P4061][CodePlus 2017 11月赛]大吉大利,今晚吃鸡!(最短路+拓扑排序+传递闭包+map+bitset(hash+压位))
5109: [CodePlus 2017]大吉大利,晚上吃鸡! Time Limit: 30 Sec Memory Limit: 1024 MBSubmit: 107 Solved: 57[Sub ...
- [BZOJ 2821] 作诗
Link: BZOJ 2821 传送门 Solution: 一道类似区间众数的经典分块 由于个数为偶数这样的条件不能支持快速合并 因此要先$O(n*sqrt(n))$预处理出$pre[i][j]$表示 ...