- 浏览: 4063131 次
文章分类
最新评论
-
klxh:
Android如何一次安装多个apk -
kchiu:
废话啊啊啊
TCP,socket 心跳检测 -
追求幸福:
iOS: 当发生signal 9为 kill的时候,程序直接被 ...
android和iOS平台的崩溃捕获和收集 -
andsy2008:
给的地址,没豆子呢,能单独发一份给我吗,andsy2008@1 ...
点餐订餐系统应用android源码 -
王粤新:
[b][i][u]引用[list]
[*][flash=200 ...
百度地图SDK for Android【事件监听】
UIBezierPath 的使用介绍
<wbr>使用UIBezierPath类可以创建基于矢量的路径。此类是Core Graphics框架关于path的一个封装。使用此类可以定义简单的形状,如椭圆或者矩形,或者有多个直线和曲线段组成的形状。
<div><wbr><wbr><wbr></wbr></wbr></wbr></div>
<div>1.Bezier Path 基础</div>
<div><wbr><wbr>UIBezierPath对象是CGPathRef数据类型的封装。path如果是基于矢量形状的,都用直线和曲线段去创建。我们使用直线段去创建矩形和多边形,使用曲线段去创建弧(arc),圆或者其他复杂的曲线形状。每一段都包括一个或者多个点,绘图命令定义如何去诠释这些点。每一个直线段或者曲线段的结束的地方是下一个的开始的地方。每一个连接的直线或者曲线段的集合成为subpath。一个UIBezierPath对象定义一个完整的路径包括一个或者多个subpaths。</wbr></wbr></div>
<div><br></div>
<div><wbr><wbr>创建和使用一个path对象的过程是分开的。创建path是第一步,包含一下步骤:</wbr></wbr></div>
<div>(1)创建一个path对象。</div>
<div>(2)使用方法moveToPoint:去设置初始线段的起点。</div>
<div>(3)添加line或者curve去定义一个或者多个subpaths。</div>
<div>(4)改变UIBezierPath对象跟绘图相关的属性。例如,我们可以设置stroked path的属性lineWidth和lineJoinStyle。也可以设置filled path的属性usesEvenOddFillRule。</div>
<div><br></div>
<div><wbr><wbr>当创建path,我们应该管理path上面的点相对于原点(0,0),这样我们在随后就可以很容易的移动path了。为了绘制path对象,我们要用到stroke和fill方法。这些方法在current graphic context下渲染path的line和curve段。</wbr></wbr></div>
<div><br></div>
<div><br></div>
<div>2.在path下面添加线或者多边形。</div>
<div>线和多边形是一些简单的形状,我们可以用moveToPoint:或者addLineToPoint:方法去构建。方法moveToPoint:设置我们想要创建形状的起点。从这点开始,我们可以用方法addLineToPoint:去创建一个形状的线段。我们可以连续的创建line,每一个line的起点都是先前的终点,终点就是指定的点。</div>
<div><br></div>
<div>下面的代码描述了如何用线段去创建一个五边形。第五条线通过调用closePath方法得到的,它连接了最后一个点(0,40)和第一个点(100,0)</div>
<div>
<table style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:4px; padding-left:0px; line-height:normal; width:980px; background-color:rgb(241,245,249); border-collapse:collapse; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(199,207,213); border-right-color:rgb(199,207,213); border-bottom-color:rgb(199,207,213); border-left-color:rgb(199,207,213)"><tbody>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">UIBezierPath* aPath = [UIBezierPath bezierPath];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Set the starting point of the shape.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">[aPath moveToPoint:CGPointMake(100.0, 0.0)];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Draw the lines
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">[aPath addLineToPoint:CGPointMake(200.0, 40.0)];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">[aPath addLineToPoint:CGPointMake(160, 140)];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">[aPath addLineToPoint:CGPointMake(40.0, 140)];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">[aPath addLineToPoint:CGPointMake(0.0, 40.0)];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">[aPath closePath];
</pre>
</td>
</tr>
</tbody></table>
</div>
<div>closePath方法不仅结束一个shape的subpath表述,它也在最后一个点和第一个点之间画一条线段,如果我们画多边形的话,这个一个便利的方法我们不需要去画最后一条线。</div>
<div><br></div>
<div><br></div>
<div>3.在path中添加arcs</div>
<div>UIBezierPath类对用arc段去初始化一个new path对象提供了支持。方法<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/clm/UIBezierPath/bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:" target="_self" style="text-decoration:underline; color:rgb(51,102,204)">bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:</a></code><wbr></wbr></span>的参数定义了我们想要的arc的圆,以及arc的起点和终点。</div>
<div>下图就是创建的一个,arc是在顺时针(clockwise)的情况下创建的。(如果在逆时针方向创建的话,则为图中虚线部分)</div>
<div><img src="http://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/Art/Arc_layout.jpg" name="image_operate_2221307172208713" alt="[转载]IOS--关于Drawing(4)[使用Bezier<wbr>Paths]" title="[转载]IOS--关于Drawing(4)[使用Bezier<wbr>Paths]" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial"></div>
<div><br></div>
<div>下面是代码实现:</div>
<div>
<p style="margin-top:1.667em; margin-right:0px; margin-bottom:-0.85em; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial; word-wrap:normal; word-break:normal; line-height:normal; font:normal normal normal 100%/normal 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; clear:both">
<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px">Creating a new arc path</span></p>
<div style="clear:both; font-size:12px; margin-top:1.5em; margin-right:0px; margin-bottom:1.5em; margin-left:0px">
<table style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:4px; padding-left:0px; line-height:normal; width:980px; background-color:rgb(241,245,249); border-collapse:collapse; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(199,207,213); border-right-color:rgb(199,207,213); border-bottom-color:rgb(199,207,213); border-left-color:rgb(199,207,213)"><tbody>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// pi is approximately equal to 3.14159265359
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">#define DEGREES_TO_RADIANS(degrees) ((pi * degrees)/ 180)
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">- (UIBezierPath*)createArcPath
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">{
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150)
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> radius:75
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> startAngle:0
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> endAngle:DEGREES_TO_RADIANS(135)
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> clockwise:YES];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> return aPath;
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">}
</pre>
</td>
</tr>
</tbody></table>
</div>
</div>
<div>如果我们想要把arc 段加入到path中,我们必须直接修改path对象的CGPathRef数据类型。</div>
<div><br></div>
<div>4.在path中添加curve。</div>
<div>UIBezierPath类提供了添加立方和二次贝塞尔曲线的支持。曲线段在当前点开始,在指定的点结束。曲线的形状有开始点,结束点,一个或者多个控制点的切线定义。下图显示了两种曲线类型的相似,以及控制点和curve形状的关系。</div>
<div><img src="http://developer.apple.com/library/ios/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/Art/curve_segments.jpg" name="image_operate_57421307173857062" alt="[转载]IOS--关于Drawing(4)[使用Bezier<wbr>Paths]" title="[转载]IOS--关于Drawing(4)[使用Bezier<wbr>Paths]" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial"></div>
<div>通过下面两个方法可以添加曲线path。</div>
<div>
<ul style="margin-top:0px; margin-right:0px; margin-bottom:0.833em; margin-left:1.35em; padding-top:0px; padding-right:0px; padding-bottom:0.5em; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:disc; list-style-position:outside">
<li style="margin-top:0.583em; margin-right:0px; margin-bottom:0px; margin-left:30px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:disc; list-style-position:initial">
<p style="margin-top:0.667em; margin-right:0px; margin-bottom:0.833em; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial; word-wrap:normal; word-break:normal; line-height:normal; font:normal normal normal 100%/normal 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; display:inline">
<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><span style="font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><strong>Cubic curve:</strong></span><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/instm/UIBezierPath/addCurveToPoint:controlPoint1:controlPoint2:" target="_self" style="text-decoration:none; color:rgb(51,102,204)">addCurveToPoint:controlPoint1:controlPoint2:</a></code></span></p>
</li>
<li style="margin-top:0.583em; margin-right:0px; margin-bottom:0px; margin-left:30px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:disc; list-style-position:initial">
<p style="margin-top:0.667em; margin-right:0px; margin-bottom:0.833em; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial; word-wrap:normal; word-break:normal; line-height:normal; font:normal normal normal 100%/normal 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; display:inline">
<span style="font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><strong>Quadratic curve:</strong></span><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/instm/UIBezierPath/addQuadCurveToPoint:controlPoint:" target="_self" style="text-decoration:none; color:rgb(51,102,204)">addQuadCurveToPoint:controlPoint:</a></code></p>
</li>
</ul>
</div>
<div>因为curve依赖于path的当前点,所以在调用上面两个方法之前要设置当前点。当曲线完成之后,current点会被更新为指定的end point。</div>
<div><br></div>
<div>5.创建椭圆或者矩形path。</div>
<div><wbr><wbr><wbr>椭圆和长方形是最常见的path。都采用曲线和直线段的组合。UIBezierPath类包括<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/clm/UIBezierPath/bezierPathWithRect:" target="_self" style="text-decoration:none; color:rgb(51,102,204)">bezierPathWithRect:</a></code><wbr>and<wbr><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/clm/UIBezierPath/bezierPathWithOvalInRect:" target="_self" style="text-decoration:none; color:rgb(51,102,204)">bezierPathWithOvalInRect<wbr>:</wbr></a></code></wbr></wbr></span>方法去创建椭圆或者矩形形状的path。这两个方法都创建了一个新的path对象,并用指定的形状去初始化它们。我们可以使用返回的path对象或者根据需要去添加更多的形状。</wbr></wbr></wbr></div>
<div><br></div>
<div><wbr><wbr><wbr>如果我们想在一个存在的path对象上面添加一个矩形,则我们必须使用moveToPoint,addLinePoint,和closePath方法,此可以做任何多边形。</wbr></wbr></wbr></div>
<div><wbr><wbr><wbr>如果想在一个存在path对象上添加一个椭圆,则最简单的方法是使用core Graphics。尽管可以使用<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:Courier,Consolas,monospace; font-size:13px; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/instm/UIBezierPath/addQuadCurveToPoint:controlPoint:" target="_self" style="text-decoration:none; color:rgb(51,102,204)">addQuadCurveToPoint:controlPoint:</a></span>去创建一个近似的椭圆,core
Graphics的<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><wbr><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)"><a href="http://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGPath/Reference/reference.html#//apple_ref/c/func/CGPathAddEllipseInRect" target="_self" style="text-decoration:none; color:rgb(51,102,204)">CGPathAddEllipseInRect</a></code><wbr></wbr></wbr></span>方法非常的简单使用,也更准确。</wbr></wbr></wbr></div>
<div><br></div>
<div><br></div>
<div>6.使用Core Graphics函数去修改path。</div>
<div><wbr><wbr><wbr>UIBezierPath类只是CGPathRef数据类型和path绘图属性的一个封装。虽然通常我们可以用UIBezierPath类的方法去添加直线段和曲线段,UIBezierPath类还提供了一个属性CGPath,我们可以用来直接修改底层的path data type。如果我们希望用Core Graphics 框架函数去创建path,则我们要用到此属性。</wbr></wbr></wbr></div>
<div><br></div>
<div><wbr><wbr><wbr>有两种方法可以用来修改和UIBezierPath对象相关的path。可以完全的使用Core Graphics函数去修改path,也可以使用Core Graphics函数和UIBezierPath函数混合去修改。第一种方法在某些方面相对来说比较容易。我们可以创建一个CGPathRef数据类型,并调用我们需要修改path信息的函数。</wbr></wbr></wbr></div>
<div>下面的代码就是赋值一个新的CGPathRef给UIBezierPath对象。</div>
<div>
<table style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:4px; padding-left:0px; line-height:normal; width:980px; background-color:rgb(241,245,249); border-collapse:collapse; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(199,207,213); border-right-color:rgb(199,207,213); border-bottom-color:rgb(199,207,213); border-left-color:rgb(199,207,213)"><tbody>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Create the path data
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGMutablePathRef cgPath = CGPathCreateMutable();
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGPathAddEllipseInRect(cgPath, NULL, CGRectMake(0, 0, 300, 300));
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGPathAddEllipseInRect(cgPath, NULL, CGRectMake(50, 50, 200, 200));
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Now create the UIBezierPath object
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">UIBezierPath* aPath = [UIBezierPath bezierPath];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">aPath.CGPath = cgPath;
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">aPath.usesEvenOddFillRule = YES;
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// After assigning it to the UIBezierPath object, you can release
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// your CGPathRef data type safely.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGPathRelease(cgPath);
</pre>
</td>
</tr>
</tbody></table>
</div>
<div><wbr><wbr><wbr>如果我们使用Core Graphics函数和UIBezierPath函数混合方法,我们必须小心的移动path 信息在两者之间。因为UIBezierPath类拥有自己底层的CGPathRef data type,我们不能简单的检索该类型并直接的修改它。相反,我们应该生成一个副本,然后修改此副本,然后赋值此副本给CGPath属性,如下代码:</wbr></wbr></wbr></div>
<div>
<p style="margin-top:1.667em; margin-right:0px; margin-bottom:-0.85em; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial; word-wrap:normal; word-break:normal; line-height:normal; font:normal normal normal 100%/normal 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; clear:both">
<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><wbr>Mixing Core Graphics and<wbr><code style="font-size:13px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102)">UIBezierPath</code><wbr>calls</wbr></wbr></wbr></span></p>
<div style="clear:both; font-size:12px; margin-top:1.5em; margin-right:0px; margin-bottom:1.5em; margin-left:0px">
<table style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:4px; padding-left:0px; line-height:normal; width:980px; background-color:rgb(241,245,249); border-collapse:collapse; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(199,207,213); border-right-color:rgb(199,207,213); border-bottom-color:rgb(199,207,213); border-left-color:rgb(199,207,213)"><tbody>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect<wbr>:CGRectMake(0, 0, 300, 300)];
</wbr></pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Get the CGPathRef and create a mutable version.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGPathRef cgPath = aPath.CGPath;
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGMutablePathRef mutablePath = CGPathCreateMutableCopy(cgPath);
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Modify the path and assign it back to the UIBezierPath object
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGPathAddEllipseInRect(mutablePath, NULL, CGRectMake(50, 50, 200, 200));
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">aPath.CGPath = mutablePath;
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">// Release both the mutable copy of the path.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">CGPathRelease(mutablePath);
</pre>
</td>
</tr>
</tbody></table>
</div>
</div>
<div><br></div>
<div>7.rendering(渲染)Bezier Path对象的内容。</div>
<div><wbr><wbr>当创建一个UIBezierPath对象之后,我们可以使用它的stroke和fill方法在current graphics context中去渲染它。在调用这些方法之前,我们要进行一些其他的任务去确保正确的绘制path。</wbr></wbr></div>
<div><wbr><wbr>使用UIColor类的方法去stroke和fill想要的颜色。</wbr></wbr></div>
<div><wbr><wbr>设置形状在目标视图中的位置。如果我们创建的path相对于原点(0,0),则我们可以给current drawing context应用一个适当的affie transform。例如,我想drawing一个形状起始点在(0,0),我可以调用函数CGContextTranslateCTM,并指定水平和垂直方向的translation值为10。调整graphic context相对于调整path对象的points是首选的方法,因为我们可以很容易的保存和撤销先前的graphics
state。</wbr></wbr></div>
<div><wbr><wbr><wbr>更新path对象的drawing 属性。当渲染path时,UIBezierPath实例的drawing属性会覆盖graphics context下的属性值。</wbr></wbr></wbr></div>
<div><br></div>
<div><wbr><wbr>下面的代码实现了在一个自定义view中实现drawRect:方法中去绘制一个椭圆。椭圆边框矩形的左上角位于视图坐标系统的点(50,50)处。</wbr></wbr></div>
<div>
<p style="margin-top:1.667em; margin-right:0px; margin-bottom:-0.85em; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; border-style:initial; border-color:initial; list-style-type:none; list-style-position:initial; word-wrap:normal; word-break:normal; line-height:normal; font:normal normal normal 100%/normal 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; clear:both">
<span style="word-wrap:normal; word-break:normal; line-height:normal; font-family:'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; font-size:13px"><wbr><wbr>Drawing a path in a view</wbr></wbr></span></p>
<div style="clear:both; font-size:12px; margin-top:1.5em; margin-right:0px; margin-bottom:1.5em; margin-left:0px">
<table style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:0px; padding-bottom:4px; padding-left:0px; line-height:normal; width:980px; background-color:rgb(241,245,249); border-collapse:collapse; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(199,207,213); border-right-color:rgb(199,207,213); border-bottom-color:rgb(199,207,213); border-left-color:rgb(199,207,213)"><tbody>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">- (void)drawRect:(CGRect)rect
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">{
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // Create an oval shape to draw.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> UIBezierPath* aPath = [UIBezierPath bezierPathWithOvalInRect<wbr>:
</wbr></pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> CGRectMake(0, 0, 200, 100)];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // Set the render colors
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> [[UIColor blackColor] setStroke];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> [[UIColor redColor] setFill];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> CGContextRef aRef = UIGraphicsGetCurrentCont<wbr>ext();
</wbr></pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // If you have content to draw after the shape,
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // save the current state before changing the transform
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> //CGContextSaveGState(aRef);
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // Adjust the view's origin temporarily. The oval is
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // now drawn relative to the new origin point.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> CGContextTranslateCTM(aRef, 50, 50);
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // Adjust the drawing options as needed.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> aPath.lineWidth = 5;
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // Fill the path before stroking it so that the fill
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // color does not obscure the stroked line.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> [aPath fill];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> [aPath stroke];
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> // Restore the graphics state before drawing any other content.
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px"> //CGContextRestoreGState(aRef);
</pre>
</td>
</tr>
<tr style="border-bottom-width:0px; border-bottom-style:solid; border-bottom-color:rgb(255,255,255)">
<td scope="row" style="margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0.5em; padding-right:0.5em; padding-bottom:0.5em; padding-left:0.5em; font-size:12px; font-family:Verdana,宋体,sans-serif; line-height:18px">
<pre style="white-space:pre-wrap; margin-top:-0.083em; margin-bottom:0px; font-size:12px; font-family:Courier,Consolas,monospace; color:rgb(102,102,102); margin-right:0.333em; margin-left:0.5em; line-height:13px">}</pre>
</td>
</tr>
</tbody></table>
</div>
</div>
</wbr>
相关推荐
UIBezierPath的简单介绍,希望有助于你的理解与应用
iOS中UIBezierPath画图的基本使用。
利用UIBezierPath和CAShapeLayer实现的镂空及遮罩效果。
计算tap事件点击的坐标位于饼图什么位置,以响应饼图的点击事件,显示百分比。
UIBezierPath精讲
包含所有基本动画,常用复杂动画,UIBezierPath画出爱心。
根据UIBezierPath和CAShapeLayer自定义倒计时进度条,适用于app启动的时候设置一个倒计时关闭启动页面。可以设置进度条颜色,填充颜色,进度条宽度以及点击事件等。
主要为大家详细介绍了iOS使用UIBezierPath实现ProgressView,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
UIBezierPath主要用来绘制矢量图形,它是基于Core Graphics对CGPathRef数据类型和path绘图属性的一个封装,所以是需要图形上下文的(CGContextRef),所以一般UIBezierPath在drawRect中使用。 使用方法 UIBezierPath...
UIBezierPath-Symbol:[已弃用] UIBezierPath类的符号扩展(UIBezierPath类别)
1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 3、本资源作为“参考资料”如果需要实现其他功能,...
最近在开发ios项目空闲之余,决定练习下UIBezierPath进行绘图和CAAnimation动画的使用,制作了一个心跳的动画,很简单的示例,下面话不多说了,来一起看看详细的介绍: GIF示例: 核心代码 1-首先通过 drawRect 绘制...
UIBezierPath主要用来绘制矢量图形,它是基于Core Graphics对CGPathRef数据类型和path绘图属性的一个封装,所以是需要图形上下文的(CGContextRef),所以一般UIBezierPath在drawRect中使用。 UIBezierPath的属性...
UIBezierPath CGRect rect = CGRectMake(50, 50, 50, 50); // UIBezierPath *bezierPath = [UIBezierPath bezierPath]; // //CALayer的子类 // CAShapeLayer *layer = [CAShapeLayer new]; // //轮廓的颜色 // layer...
该项目提供了一个简单的API来获取UIBezierPath或NSBezierPath的长度。 例子: let rect = CGRect ( origin : . zero , size : CGSize ( width : 100 , height : 300 )) let path = UIBezierPath ( ovalIn : rect)...
IOS绘制、编辑多边形 基于UIBezierPath
UIBezierPath + DSL提供了一种使用伪DSL构建贝塞尔曲线的简单方法。 受和启发。 ✓支持相对定位。 UIBezierPath *path = [UIBezierPath makePath: ^(DSLBezierPathMaker *make) { make. moveTo ( CGPointMake ...