UIBizerPath官方API翻譯

18- UIBezierPath官方API中文翻譯(待校對)

----------------- 華麗的分割線 -----------------

這篇文章是我自己一個(gè)人翻譯的,里邊肯定有不順暢的地方和不準(zhǔn)確的地方.自己英語水平有限,發(fā)出來是想讓大家一起看看文章哪些地方不準(zhǔn)確!!!下邊帶橫線的句子就是我最不確定的地方.當(dāng)然其它地方也是可能可能有問題的!英語比較好的同學(xué)和有精力的同學(xué)歡迎一起看下歌粥,在留言部分指出熏瞄,我會(huì)把你的id一起加到修改的地方~~~好了,讓我們一起翻譯校對一個(gè)api吧绍在!
前言
這幾天在看kittenYang的那本動(dòng)畫的書.感覺學(xué)習(xí)一下動(dòng)畫的實(shí)現(xiàn)還是有必要的.而說起來做動(dòng)畫,貝塞爾曲線這個(gè)東西我們就必須了解了.為此,自己本著好好學(xué)習(xí),了解權(quán)威的目的,決定翻譯一下官方的關(guān)于UIBezierPath這部分的 API.
但是
我英語真的不好

我英語真的不怎么樣,這個(gè)不是謙虛...大學(xué)沒過四級,這不是最慘的.... 慘的是我考了三次?四次?....安慰的是最好成績是424,距離四級及格線只差一分.
所以,我說這個(gè)的目的就是告訴大家!!!!!這篇翻譯文章中,會(huì)有一些不太通順地方,還有一些錯(cuò)誤的地方.我竭盡自己的能力為大家盡可能準(zhǔn)確的翻一下,在這里也要感謝我上211的妹妹,一個(gè)家族的,英語差距咋這么大捏~~~~當(dāng)然只有幾句是妹妹看的.....因?yàn)?她的愿望是:自己的事情自己做!!
翻譯正文:
UIBezierPath
繼承自: NSObject
符合???: NSCoding,NSObject,NSCopying
Framework: UIKit in iOS 3.0 and later.更多相關(guān)項(xiàng)目...

The UIBezierPath class lets you define a path consisting of straight and curved line segments and render that path in your custom views. You use this class initially to specify just the geometry for your path. Paths can define simple shapes such as rectangles, ovals, and arcs or they can define complex polygons that incorporate a mixture of straight and curved line segments. After defining the shape, you can use additional methods of this class to render the path in the current drawing context.

UIBezierPath可以讓你定義一條路徑,這條路徑可以由直線和曲線線段組成,然后渲染到你的自定義的視圖中.你最開始可以用這個(gè)類來指定路徑的幾何形狀.路徑既可以定義一些簡單圖形,比如說矩形,橢圓形和弧形,又可以定義其它一些復(fù)雜的由直線和曲線線段組合成的多邊形. 當(dāng)定義完圖形形狀之后,你可以用這個(gè)類提供的額外方法把路徑添加到當(dāng)前正在繪制的上下文context中.
A UIBezierPath object combines the geometry of a path with attributes that describe the path during rendering. You set the geometry and attributes separately and can change them independent of one another. Once you have the object configured the way you want it, you can tell it to draw itself in the current context. Because the creation, configuration, and rendering process are all distinct steps, Bezier path objects can be reused easily in your code. You can even use the same object to render the same shape multiple times, perhaps changing the rendering options between successive drawing calls.

一個(gè)UIBezierPath對象包括了路徑path在繪制過程當(dāng)中的屬性.你分別設(shè)置圖形及其屬性,可以達(dá)到單獨(dú)改變他們的效果.一旦你創(chuàng)建創(chuàng)建了這個(gè)對象并且設(shè)置了你想要它實(shí)現(xiàn)效果的屬性,你就可以讓它用當(dāng)前的圖形上下文context繪制出自己.因?yàn)閯?chuàng)建,設(shè)置屬性,和渲染進(jìn)度都是不同的步驟,所以你可以用你的代碼來重復(fù)使用貝塞爾路徑對象們.你甚至可以用同一個(gè)貝塞爾路徑對象渲染同樣的圖形多次或者在連續(xù)兩次繪制請求之間改變渲染的效果屬性.
You set the geometry of a path by manipulating the path’s current point. When you create a new empty path object, the current point is undefined and must be set explicitly. To move the current point without drawing a segment, you use the moveToPoint: method. All other methods result in the addition of either a line or curve segments to the path. The methods for adding new segments always assume you are starting at the current point and ending at some new point that you specify. After adding the segment, the end point of the new segment automatically becomes the current point.

你可以通過控制路徑的當(dāng)前的(起始)點(diǎn)來設(shè)置一條路徑的形狀.當(dāng)你創(chuàng)建了一個(gè)新的空的路徑對象,如果當(dāng)前的(起始)點(diǎn)是未定義的狀態(tài),那么你必須明確的定義這個(gè)點(diǎn).為了移動(dòng)當(dāng)前的(起始)點(diǎn)而不是繪制一條線段,你需要使用moveToPoint這個(gè)方法.剩下所有的方法的作用都是在這個(gè)路徑上添加一條線或者是曲線線段.這些增加新線段的方法總是假設(shè)(為毛假設(shè)??)你在當(dāng)前的(起始)點(diǎn)開始,并在明確指定的一些新點(diǎn)結(jié)束.當(dāng)一條的線段添加完之后,這條線段的結(jié)束點(diǎn)有自動(dòng)成了下一條新線段的當(dāng)前的(起始)點(diǎn).
A single Bezier path object can contain any number of open or closed subpaths, where each subpath represents a connected series of path segments. Calling the closePath method closes a subpath by adding a straight line segment from the current point to the first point in the subpath. Calling the moveToPoint: method ends the current subpath (without closing it) and sets the starting point of the next subpath. The subpaths of a Bezier path object share the same drawing attributes and must be manipulated as a group. To draw subpaths with different attributes, you must put each subpath in its own UIBezierPath object.

一個(gè)單一的貝塞爾路徑對象能夠包含任意數(shù)量的開放和閉合的子路徑,其中每一個(gè)子路徑代表了一個(gè)路徑線段的關(guān)聯(lián)系列(??翻譯的不太好). 調(diào)用closePath方法關(guān)閉一個(gè)子路徑通過增加一條直線線段的方式,這天直線線段從當(dāng)前(起始)點(diǎn)開始到子路徑第一個(gè)點(diǎn)結(jié)束的(???形成閉合的圖形).調(diào)用moveToPoint方法結(jié)束當(dāng)前子路徑(并沒有關(guān)閉這個(gè)路徑)然后把這個(gè)點(diǎn)設(shè)置成為嚇一跳子路徑的開始點(diǎn).一個(gè)貝塞爾對象的子路徑們必須放到在同一組操作才能共享相同的繪制屬性.同樣,為了繪制具有不同特性的子路徑,你需要把每一個(gè)子路徑放到他們自己所屬的UIBezierPath對象中.
After configuring the geometry and attributes of a Bezier path, you draw the path in the current graphics context using the stroke and fill methods. The stroke method traces the outline of the path using the current stroke color and the attributes of the Bezier path object. Similarly, the fill method fills in the area enclosed by the path using the current fill color. (You set the stroke and fill color using the UIColor class.)

當(dāng)你配置好貝塞爾路徑的形狀和屬性之后,你可以利用當(dāng)前創(chuàng)建的圖形上下文(graphics context)通過stroke和fill方法繪制這個(gè)貝塞爾路徑.stroke方法可以利用當(dāng)前設(shè)置的stroke顏色和所屬的貝塞爾路徑對象的屬性來描繪路徑的輪廓.近似的,fill方法可以用當(dāng)前設(shè)置的fill顏色填充路徑圍起來的區(qū)域.(你可以利用UIColor這個(gè)類來設(shè)置stroke顏色和fill顏色.)
In addition to using a Bezier path object to draw shapes, you can also use it to define a new clipping region. The addClip method intersects the shape represented by the path object with the current clipping region of the graphics context. During subsequent drawing, only content that lies within the new intersection region is actually rendered to the graphics context.

除了可以用貝塞爾路徑對象去繪制圖形,你還可以利用它去定義個(gè)新的裁剪區(qū)域.addClip方法通過當(dāng)前圖形上下文裁剪的區(qū)域的路徑對象來表示兩個(gè)圖形的相交. 在隨后的繪制過程中,只有處在新的交集區(qū)域內(nèi)的內(nèi)容實(shí)際上是被圖形上下文繪制的??
Creating a UIBezierPath Object
創(chuàng)建一個(gè)UIBezierpath對象

  • bezierPath
    Creates and returns a new UIBezierPath object.
    創(chuàng)建并且返回一個(gè)新的UIBezrierPath對象

描述(Declaration):
//Objective-C

  • (instancetype)bezierPath
    返回值(Return Value):
    A new empty path object.
    一個(gè)新的空白的路徑對象

作用范圍(Availability):
Available in iOS 3.2 and later.
作用在iOS3.0及其之后

  • bezierPathWithRect
    Creates and returns a new UIBezierPath object initialized with a rectangular path.
    創(chuàng)建并且返回一個(gè)新的UIBezierPath對象,這個(gè)對象根據(jù)一個(gè)矩形的路徑進(jìn)行初始化

描述(Declaration):
//Swift
convenience init(rect rect: CGRect)
//Objective-C
+ (instancetype)bezierPathWithRect:(CGRect)rect
參數(shù)(Parameters):
rect | The rectangle describing the path to create.
rect | 這個(gè)矩形定義了路徑的創(chuàng)建

返回值(Return Value):
A new path object with the rectangular path.
一個(gè)包含矩形路徑的路徑對象.

論述(Discussion):
This method creates a closed subpath by starting at the origin of rect and adding line segments in a clockwise direction (relative to the default coordinate system).
這個(gè)方法從矩形的起始點(diǎn)開始,然后順時(shí)針(相對于默認(rèn)的坐標(biāo)位而言)增加線段創(chuàng)建一個(gè)閉合的路徑.

作用范圍(Availability):
Available in iOS 3.2 and later.
作用在iOS3.2及其之后.

  • bezierPathWithOvalInRect:
    Creates and returns a new UIBezierPath object initialized with an oval path inscribed in the specified rectangle

創(chuàng)建并且返回一個(gè)新的UIBezierPath對象,這個(gè)對象是在指定的矩形上初始化的橢圓路徑

描述(Declaration):
//Swift
convenience init(ovalInRect rect: CGRect)
//Objective-C

  • (instancetype)bezierPathWithOvalInRect:(CGRect)rect
    參數(shù)(Parameters):
    rect | The rectangle in which to inscribe an oval.
    rect | 在這個(gè)矩形區(qū)域內(nèi)有一個(gè)橢圓路徑

返回值(Return Value):
A new path object with the oval path.
橢圓路徑的一種新的路徑對象.

論述(Discussion):
This method creates a closed subpath that approximates the oval using a sequence of Bézier curves. The path is created in a clockwise direction (relative to the default coordinate system). If the rect parameter specifies a square, the inscribed path is a circle.
這個(gè)方法用貝塞爾(Bézier)曲線的一個(gè)序列創(chuàng)建一條閉合的近似于橢圓的子路徑.這條路徑被順時(shí)針創(chuàng)建(相對于系統(tǒng)默認(rèn)的坐標(biāo)軸).如果參數(shù)rect指定了一個(gè)正方形,那么內(nèi)接的路徑是一個(gè)圓.

作用范圍(Availability):
Available in iOS 3.2 and later.

  • bezierPathWithRoundedRect:cornerRadius:
    Creates and returns a new UIBezierPath object initialized with a rounded rectangular path.
    根據(jù)圓角矩形路徑進(jìn)行初始化,創(chuàng)建并且返回一個(gè)UIBezierPath對象

描述(Declaration):
//Swift
convenience init(roundedRect rect: CGRect,
cornerRadius cornerRadius: CGFloat)
//Objective-C

  • (instancetype)bezierPathWithRoundedRect:(CGRect)rect
    cornerRadius:(CGFloat)cornerRadius
    參數(shù)(Parameters):
    rect The rectangle that defines the basic shape of the path
    cornerRadius The radius of each corner oval. A value of 0 results in a rectangle without rounded corners. Values larger than half the rectangle’s width or height are clamped appropriately to half the width or height.
    rect 該矩形定義了路徑的基本形狀
    cornerRadius 每一個(gè)圓角的半徑.當(dāng)指定一個(gè)值為0時(shí),效果會(huì)是一個(gè)沒有圓角的矩形. 指定的值大于矩形寬度或者高度的一半被適當(dāng)?shù)膴A持于寬度和高度的一半(啥玩意)???
    返回值(Return Value):
    A new path object with the rounded rectangular path.
    圓角矩形路徑的一種新的路徑對象.

論述(Discussion):
This method creates a closed subpath, proceeding in a clockwise direction (relative to the default coordinate system) as it creates the necessary line and curve segments.
這個(gè)方法創(chuàng)建一個(gè)閉合子路徑,然后當(dāng)他設(shè)置了必要的線和曲線段時(shí)繼續(xù)沿著順時(shí)針方向(相對于默認(rèn)的系統(tǒng)坐標(biāo)系).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:
    Creates and returns a new UIBezierPath object initialized with a rounded rectangular path.
    根據(jù)圓角矩形路徑進(jìn)行初始化,創(chuàng)建并且返回一個(gè)UIBezierPath對象

描述(Declaration):
//Swift
convenience init(roundedRect rect: CGRect,
byRoundingCorners corners: UIRectCorner,
cornerRadii cornerRadii: CGSize)
//Objective-C

  • (instancetype)bezierPathWithRoundedRect:(CGRect)rect
    byRoundingCorners:(UIRectCorner)corners
    cornerRadii:(CGSize)cornerRadii
    參數(shù)(Parameters):
    rect The rectangle that defines the basic shape of the path.
    corners A bitmask value that identifies the corners that you want rounded. You can use this parameter to round only a subset of the corners of the rectangle.
    cornerRadii The radius of each corner oval. Values larger than half the rectangle’s width or height are clamped appropriately to half the width or height.
    rect 這個(gè)矩形定義了路徑的基本形狀
    corners 一個(gè)掩碼值定義了你想要變成圓的角.你可以利用這個(gè)屬性讓矩形的四個(gè)角的其中一個(gè)或者幾個(gè)變圓.
    cornerRadii 每一個(gè)圓角的半徑. 指定的值大于矩形寬度或者高度的一半被適當(dāng)?shù)膴A持于寬度和高度的一半(啥玩意)???
    返回值(Return Value):
    A new path object with the rounded rectangular path.
    圓角矩形路徑的一個(gè)新的路徑對象.

論述(Discussion):
This method creates a closed subpath, proceeding in a clockwise direction (relative to the default coordinate system) as it creates the necessary line and curve segments.
這個(gè)方法創(chuàng)建一個(gè)閉合子路徑,然后當(dāng)他設(shè)置了必要的線和曲線段時(shí)繼續(xù)沿著順時(shí)針方向(相對于默認(rèn)的系統(tǒng)坐標(biāo)系).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:
    Creates and returns a new UIBezierPath object initialized with an arc of a circle.
    根據(jù)圓的一段圓弧進(jìn)行初始化,創(chuàng)建并返回一個(gè)新的UIBezierPath 對象

描述(Declaration):
//Swift
convenience init(arcCenter center: CGPoint,
radius radius: CGFloat,
startAngle startAngle: CGFloat,
endAngle endAngle: CGFloat,
clockwise clockwise: Bool)
//Objective-C

  • (instancetype)bezierPathWithArcCenter:(CGPoint)center
    radius:(CGFloat)radius
    startAngle:(CGFloat)startAngle
    endAngle:(CGFloat)endAngle
    clockwise:(BOOL)clockwise
    參數(shù)(Parameters):
    center Specifies the center point of the circle (in the current coordinate system) used to define the arc.
    radius Specifies the radius of the circle used to define the arc.
    startAngle Specifies the starting angle of the arc (measured in radians).
    endAngle Specifies the end angle of the arc (measured in radians).
    clockwise The direction in which to draw the arc.
    center 指定圓的中心點(diǎn)(在當(dāng)前的坐標(biāo)系統(tǒng))用來定義弧形.
    radius 指定圓的半徑用來定義弧形.
    startAngle 指定圓弧的起始角度(按弧度).
    endAngle 指定弧形的結(jié)束角度(按弧度).
    clockwise 繪制弧形的方向.
    返回值(Return Value):
    A new path object with the specified arc.
    一個(gè)指定了弧的新的路徑對象.

論述(Discussion):
This method creates an open subpath. The created arc lies on the perimeter of the specified circle. When drawn in the default coordinate system, the start and end angles are based on the unit circle shown in Figure 1. For example, specifying a start angle of 0 radians, an end angle of π radians, and setting the clockwise parameter to YES draws the bottom half of the circle. However, specifying the same start and end angles but setting the clockwise parameter set to NO draws the top half of the circle.
這個(gè)方法創(chuàng)建出一個(gè)開發(fā)的子路徑.它創(chuàng)建的弧線處在指定圓的周邊的邊上.當(dāng)在默認(rèn)的坐標(biāo)系統(tǒng)上繪制時(shí),起始和結(jié)束的角度是基于單位圓,如 圖-1 展示.舉個(gè)例子,指定起始弧度是0,結(jié)束弧度是π,同時(shí)設(shè)置參數(shù)clockwise 是YES,繪制出的是一個(gè)圓形的下半部分.然而,指定相同的起始和結(jié)束角,但是設(shè)置參數(shù)clockwise為NO,繪制出的是圓形的上半部分.

Figure 1 Angles in the default coordinate system
圖-1 在默認(rèn)坐標(biāo)系中的角度

After calling this method, the current point is set to the point on the arc at the end angle of the circle.
調(diào)用了這個(gè)方法之后,起始點(diǎn)又被設(shè)置成為圓的結(jié)束角的弧線上的點(diǎn).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • bezierPathWithCGPath:
    Creates and returns a new UIBezierPath object initialized with the contents of a Core Graphics path.
    根據(jù)一個(gè)核心圖形路徑的內(nèi)容進(jìn)行初始化,創(chuàng)建并返回一個(gè)新的UIBezierPath對象.

描述(Declaration):
//Swift
convenience init(CGPath CGPath: CGPath)
//Objective-C

  • (instancetype)bezierPathWithCGPath:(CGPathRef)CGPath
    參數(shù)(Parameters):
    CGPath | The Core Graphics path from which to obtain the initial path information. If this parameter is nil, the method raises an exception.

CGPath | 核心圖形路徑從初始路徑信息的獲取???.如果這個(gè)參數(shù)為nil,這個(gè)方法將會(huì)發(fā)生異常.

返回值(Return Value):
A new path object with the specified path information.
指定了路徑信息的一條新的路徑對象.

作用范圍(Availability):
Available in iOS 3.2 and later.

  • bezierPathByReversingPath
    Creates and returns a new bezier path object with the reversed contents of the current path.
    根據(jù)一個(gè)顛倒的當(dāng)前路徑的內(nèi)容,創(chuàng)建并且返回一個(gè)新的貝塞爾路徑對象.

描述(Declaration):
//Swift
func bezierPathByReversingPath() -> UIBezierPath
//Objective-C

  • (UIBezierPath *)bezierPathByReversingPath
    返回值(Return Value):
    A new path object with the same path shape but for which the path has been created in the reverse direction.
    一個(gè)新的路徑對象具有相同的路徑形狀,單該路徑已經(jīng)在相反的方向被創(chuàng)建了.

論述(Discussion):
Reversing a path does not necessarily change the appearance of the path when rendered. Instead, it changes the direction in which path segments are drawn. For example, reversing the path of a rectangle (whose line segments are normally drawn starting at the origin and proceeding in a counterclockwise direction) causes its line segments to be drawn in a clockwise direction instead. Drawing a reversed path could affect the appearance of a filled pattern, depending on the pattern and the fill rule in use.
當(dāng)要展示的時(shí)候,倒轉(zhuǎn)一條路徑不一定非要改變它的外觀.相反,他改變的是已經(jīng)繪制的路徑線段的方向.舉個(gè)例子:倒轉(zhuǎn)一條矩形(它的線段通常是在原點(diǎn)繪制,然后繼續(xù)沿著逆時(shí)針方向)的路徑導(dǎo)致它的線段沿順時(shí)針相反方向被繪制.繪制一個(gè)倒轉(zhuǎn)的路徑能夠影響填充模式的形態(tài),取決于模式和使用的填充規(guī)則.

This method reverses each whole or partial subpath in the path object individually.
這個(gè)方法倒轉(zhuǎn)每一個(gè)整體或者單獨(dú)路徑對象的部分子路徑.

作用范圍(Availability):
Available in iOS 6.0 and later.

Constructing a Path
構(gòu)建一個(gè)路徑

  • moveToPoint:
    Moves the receiver’s current point to the specified location.
    移動(dòng)方法接收者的當(dāng)前點(diǎn)到指定為位置.

描述(Declaration):
//Swift
func moveToPoint(_ point: CGPoint)
//Objective-C

  • (void)moveToPoint:(CGPoint)point
    參數(shù)(Parameters):
    point | A point in the current coordinate system.

point | 在當(dāng)前坐標(biāo)系統(tǒng)的點(diǎn).

論述(Discussion):
This method implicitly ends the current subpath (if any) and sets the current point to the value in the point parameter. When ending the previous subpath, this method does not actually close the subpath. Therefore, the first and last points of the previous subpath are not connected to each other.
這個(gè)方法比較隱式的結(jié)束當(dāng)前的子路徑(如果有的話),同時(shí)設(shè)置當(dāng)前點(diǎn)為參數(shù)point的值.當(dāng)結(jié)束上一個(gè)子路徑之后,這個(gè)方法并不會(huì)真正的關(guān)閉子路徑.因此,上一條子路徑的第一個(gè)和最后一個(gè)點(diǎn)不會(huì)彼此連接起來.

For many path operations, you must call this method before issuing any commands that cause a line or curve segment to be drawn.
對于多條路徑的操作,你必須在發(fā)起任何一個(gè)使得線段和曲線段被繪制的命令之前調(diào)用這個(gè)方法.

作用范圍(Availability):
Available in iOS 3.2 and later.

  • addLineToPoint:
    Appends a straight line to the receiver’s path.
    在當(dāng)前方法接收者的路徑上添加上一條直線.

描述(Declaration):
//Swift
func addLineToPoint(_ point: CGPoint)
//Objective-C

  • (void)addLineToPoint:(CGPoint)point
    參數(shù)(Parameters):
    point | The destination point of the line segment, specified in the current coordinate system.

point | 這個(gè)線段的終點(diǎn), 在當(dāng)前的坐標(biāo)系中指定.

論述(Discussion):
This method creates a straight line segment starting at the current point and ending at the point specified by the point parameter. After adding the line segment, this method updates the current point to the value in point.
這個(gè)方法創(chuàng)建一條從當(dāng)前點(diǎn)開始,到參數(shù)point指定的點(diǎn)結(jié)束的直線線段.當(dāng)增加這條線段之后,這個(gè)方法更新當(dāng)前的當(dāng)前點(diǎn)為參數(shù)point的值.

You must set the path’s current point (using the moveToPoint:method or through the previous creation of a line or curve segment) before you call this method. If the path is empty, this method does nothing.
在你調(diào)用這個(gè)方法之前,你必須設(shè)置路徑的當(dāng)前點(diǎn)(使用moveToPoint方法或者通過前一個(gè)創(chuàng)建先或者曲線線段).如果這個(gè)路徑為空,那么這個(gè)方法不做任何事情.

作用范圍(Availability):
Available in iOS 3.2 and later.

  • addArcWithCenter:radius:startAngle:endAngle:clockwise:
    Appends an arc to the receiver’s path.
    給方法接收者的路徑中添加一個(gè)弧.

描述(Declaration):
//Swift
func addArcWithCenter(_ center: CGPoint,
radius radius: CGFloat,
startAngle startAngle: CGFloat,
endAngle endAngle: CGFloat,
clockwise clockwise: Bool)
//Objective-C

  • (void)addArcWithCenter:(CGPoint)center
    radius:(CGFloat)radius
    startAngle:(CGFloat)startAngle
    endAngle:(CGFloat)endAngle
    clockwise:(BOOL)clockwise
    參數(shù)(Parameters):
    center Specifies the center point of the circle (in the current coordinate system) used to define the arc.
    radius Specifies the radius of the circle used to define the arc.
    startAngle Specifies the starting angle of the arc (measured in radians).
    endAngle Specifies the end angle of the arc (measured in radians).
    clockwise The direction in which to draw the arc.
    center 用來定義弧而指定的圓的中心點(diǎn)(在當(dāng)前坐標(biāo)系中)
    radius 用來定義弧而指定的圓的的半徑
    startAngle 指定弧的起始角度(用弧度衡量)
    endAngle 指定弧的結(jié)束角度(用弧度衡量)
    clockwise 畫弧的方向
    論述(Discussion):
    This method adds the specified arc beginning at the current point. The created arc lies on the perimeter of the specified circle. When drawn in the default coordinate system, the start and end angles are based on the unit circle shown in Figure 1. For example, specifying a start angle of 0 radians, an end angle of π radians, and setting the clockwise parameter to YES draws the bottom half of the circle. However, specifying the same start and end angles but setting the clockwise parameter set to NO draws the top half of the circle.
    這個(gè)方法增加一個(gè)在當(dāng)前點(diǎn)開始的弧.這個(gè)弧線在指定圓的周長的邊上.當(dāng)在默認(rèn)坐標(biāo)系上繪制的時(shí)候,開始和結(jié)束角度基于圖-1展示的單位圓的基礎(chǔ)上的.舉個(gè)例子:指定起始角度是0度和結(jié)束角度是π.并設(shè)置參數(shù)clockwise為YES,繪制出的效果是圓的下半部分.然而,指定相同的起始和結(jié)束角度但是這只參數(shù)clockwise為NO,繪制出的效果是圓的上邊的一半.

After calling this method, the current point is set to the point on the arc at the end angle of the circle.
當(dāng)調(diào)用這個(gè)方法之后,當(dāng)前點(diǎn)被設(shè)置為圓的結(jié)束度對應(yīng)弧上的點(diǎn).

作用范圍(Availability):
Available in iOS 4.0 and later.

  • addCurveToPoint:controlPoint1:controlPoint2:(重要)
    Appends a cubic Bézier curve to the receiver’s path.
    給方法的接收的路徑中添加一個(gè)立體的貝塞爾曲線

描述(Declaration):
//Swift
func addCurveToPoint(_ endPoint: CGPoint,
controlPoint1 controlPoint1: CGPoint,
controlPoint2 controlPoint2: CGPoint)
//Objective-C

  • (void)addCurveToPoint:(CGPoint)endPoint
    controlPoint1:(CGPoint)controlPoint1
    controlPoint2:(CGPoint)controlPoint2
    參數(shù)(Parameters):
    endPoint The end point of the curve.
    controlPoint1 The first control point to use when computing the curve.
    controlPoint2 The second control point to use when computing the curve.
    endPoint 曲線的結(jié)束角度
    controlPoint1 計(jì)算曲線時(shí)使用的第一個(gè)控制點(diǎn)
    controlPoint2 計(jì)算曲線時(shí)使用的第二個(gè)控制點(diǎn)
    論述(Discussion):
    This method appends a cubic Bézier curve from the current point to the end point specified by the endPoint parameter. The two control points define the curvature of the segment. Figure 2 shows an approximation of a cubic Bézier curve given a set of initial points. The exact curvature of the segment involves a complex mathematical relationship between all of the points and is well documented online.
    這個(gè)方法提供了一個(gè)從當(dāng)前(起始)點(diǎn)開始到參數(shù)endPoint指定的結(jié)束點(diǎn)結(jié)束的立體貝塞爾曲線.兩個(gè)控制點(diǎn)定義了(startPoint和endPoint連接起來的)線段的曲率(如圖-2所示).圖-2展示了一個(gè)近似貝塞爾曲線的一組初始點(diǎn). 這個(gè)線段的曲率的精度如要想十分精確, 是和所有的點(diǎn)之間和更好的記錄在線的目的有關(guān)聯(lián)的, 所以涉及到一個(gè)復(fù)雜的數(shù)學(xué)關(guān)系.

Figure 2 A cubic Bézier curve
圖-2 一個(gè)立體的貝塞爾曲線

You must set the path’s current point (using the moveToPoint: method or through the previous creation of a line or curve segment) before you call this method. If the path is empty, this method does nothing. After adding the curve segment, this method updates the current point to the value in point.
在你調(diào)用這個(gè)方法之前,你必須設(shè)置路徑的當(dāng)前(起始)點(diǎn)(用moveToPoint方法或者通過上一個(gè)創(chuàng)建的線端或者曲線段).如果這個(gè)路徑是空的,這個(gè)方法將不做任何事情.增加完這個(gè)曲線段之后,這個(gè)方法把當(dāng)前點(diǎn)更新為point的值(注:應(yīng)該是endPoint的值吧).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • addQuadCurveToPoint:controlPoint:
    Appends a quadratic Bézier curve to the receiver’s path.
    在方法接收者的路徑中添加一個(gè)二次方程式的貝塞爾曲線.

描述(Declaration):
//Swift
func addQuadCurveToPoint(_ endPoint: CGPoint,
controlPoint controlPoint: CGPoint)
//Objective-C

  • (void)addQuadCurveToPoint:(CGPoint)endPoint
    controlPoint:(CGPoint)controlPoint
    參數(shù)(Parameters):
    endPoint The end point of the curve.
    controlPoint The control point of the curve.
    endPoint 曲線的結(jié)束點(diǎn)
    controlPoint 曲線的控制點(diǎn)
    論述(Discussion):
    This method appends a quadratic Bézier curve from the current point to the end point specified by the endPoint parameter. The relationships between the current point, control point, and end point are what defines the actual curve. Figure 3 shows some examples of quadratic curves and the approximate curve shape based on some sample points. The exact curvature of the segment involves a complex mathematical relationship between the points and is well documented online.
    這個(gè)方法添加一個(gè)從當(dāng)前(起始)點(diǎn)到參數(shù)endPoint指定的結(jié)束點(diǎn)的二次方程式的貝塞爾曲線.當(dāng)前(起始)點(diǎn)、控制點(diǎn)和結(jié)束點(diǎn)的關(guān)系是定義了曲線實(shí)際的形態(tài).圖-3展示了一些基于樣本點(diǎn)繪制出的二次方程式曲線和近似曲線形狀的例子. 這個(gè)線段的曲率的精度如要想十分精確, 是和所有的點(diǎn)之間和更好的記錄在線的目的有關(guān)聯(lián)的, 所以涉及到一個(gè)復(fù)雜的數(shù)學(xué)關(guān)系.

Figure 3 Quadratic curve examples
圖-3 二次方程式的曲線的例子

You must set the path’s current point (using the moveToPoint: method or through the previous creation of a line or curve segment) before you call this method. If the path is empty, this method does nothing. After adding the curve segment, this method updates the current point to the value in point.
在你調(diào)用這個(gè)方法之前,你必須設(shè)置這個(gè)曲線的當(dāng)前(起始)點(diǎn)(使用moveToPoint:方法或者通過之前創(chuàng)建的線段或者曲線段).;如果這個(gè)路徑為空,那么這個(gè)方法不做任何事情.當(dāng)你添加完這個(gè)曲線段之后,這個(gè)方法會(huì)把更新當(dāng)前點(diǎn)為point的值.

作用范圍(Availability):
Available in iOS 3.2 and later.

  • closePath
    Closes the most recently added subpath.
    關(guān)閉最近添加的子路徑.

描述(Declaration):
//Swift
func closePath()
//Objective-C

  • (void)closePath
    論述(Discussion):
    This method closes the current subpath by creating a line segment between the first and last points in the subpath. This method subsequently updates the current point to the end of the newly created line segment, which is also the first point in the now closed subpath.
    這個(gè)方法通過創(chuàng)建一條連接子路徑中的第一個(gè)點(diǎn)和最后一個(gè)點(diǎn)的線段的方式,來關(guān)閉當(dāng)前的子路徑.這個(gè)方法隨后更新當(dāng)前(起始)點(diǎn)指向最新創(chuàng)建的線段的結(jié)束點(diǎn),也就是已經(jīng)關(guān)閉的子路徑的第一個(gè)點(diǎn).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • removeAllPoints
    Removes all points from the receiver, effectively deleting all subpaths.
    移除方法接收者的所有的點(diǎn),有效刪除所有的子路徑.

描述(Declaration):
//Swift
func removeAllPoints()
//Objective-C

  • (void)removeAllPoints
    作用范圍(Availability):
    Available in iOS 3.2 and later.

  • appendPath:
    Appends the contents of the specified path object to the receiver’s path.
    在方法接收者的路徑中添加指定路徑對象的內(nèi)容.

描述(Declaration):
//Swift
func appendPath(_ bezierPath: UIBezierPath)
//Objective-C

  • (void)appendPath:(UIBezierPath *)bezierPath
    參數(shù)(Parameters):
    bezierPath | The path to add to the receiver.
    bezierPath | 路徑,添加到方法接收者中.

論述(Discussion):
This method adds the commands used to create the path in bezierPath to the end of the receiver’s path. This method does not explicitly try to connect the subpaths in the two objects, although the operations in bezierPath might still cause that effect. 方法把用于創(chuàng)建bezierPath路徑的命令添加到了方法接收者接收者的路徑的最后. 這個(gè)方法不明確嘗試連接兩個(gè)對象的子路徑,雖然在bezierPath上的操作可能依然導(dǎo)致這種影響.

作用范圍(Availability):
Available in iOS 3.2 and later.

CGPath Property
The Core Graphics representation of the path.
路徑的核心圖形表現(xiàn).

描述(Declaration):
//Swift
var CGPath: CGPath
//Objective-C
@property(nonatomic) CGPathRef CGPath
論述(Discussion):
This property contains a snapshot of the path at any given point in time. Getting this property returns an immutable path object that you can pass to Core Graphics functions. The path object itself is owned by the UIBezierPath object and is valid only until you make further modifications to the path. 這個(gè)屬性包含在任何給定時(shí)間的點(diǎn)上的快照. 獲取這個(gè)屬性并返回一個(gè)不可改變的路徑對象,然后你可以把它傳給核心圖形的方法.這個(gè)路徑對象是屬于UIBezierPath對象的并且是有效的,直到你對路徑做出進(jìn)一步的修改.

You can set the value of this property to a path you built using the functions of the Core Graphics framework. When setting a new path, this method makes a copy of the path you provide.
你可以用核心圖形框架(Core Graphics framework)中的方法給一條路徑設(shè)置這個(gè)屬性的值.當(dāng)設(shè)置一條新的路徑的時(shí)候,這個(gè)方法會(huì)對你提供的路徑復(fù)制一份.

作用范圍(Availability):
Available in iOS 3.2 and later.

currentPoint Property
The current point in the graphics path. (read-only)
在圖形路徑上的當(dāng)前(起始)點(diǎn)(只讀).

描述(Declaration):
//Swift
var currentPoint: CGPoint { get }
//Objective-C
@property(nonatomic, readonly) CGPoint currentPoint
論述(Discussion):
The value in this property represents the starting point for new line and curve segments. If the path is currently empty, this property contains the value CGPointZero.
這個(gè)屬性的值表示新的線和曲線線段的起點(diǎn).如果這個(gè)路徑目前是空的,那么這個(gè)屬性值是CGPointZero.

作用范圍(Availability):
Available in iOS 3.2 and later.

參閱(See Also):
empty(下邊有個(gè)屬性是empty,com+F高速抵達(dá))

Accessing Drawing Properties
訪問繪制屬性
lineWidthProperty
The line width of the path.
路徑的寬度.

描述(Declaration):
//Swift
var lineWidth: CGFloat
//Objective-C
@property(nonatomic) CGFloat lineWidth
論述(Discussion):
The line width defines the thickness of the receiver's stroked path. A width of 0 is interpreted as the thinnest line that can be rendered on a particular device. The actual rendered line width may vary from the specified width by as much as 2 device pixels, depending on the position of the line with respect to the pixel grid and the current anti-aliasing settings. The width of the line may also be affected by scaling factors specified in the current transformation matrix of the active graphics context.
線寬度定義了方法接收者的描邊路徑(用筆畫的,可以和fill填充相對著理解)的厚度.寬度為0的解釋是可以在特定設(shè)備上呈現(xiàn)出來的最薄的線. 實(shí)際呈現(xiàn)出來的線寬度可能和指定的寬度有2個(gè)設(shè)備像素的不同, 根據(jù)線寬的基于像素網(wǎng)格的位置和當(dāng)前的抗鋸齒設(shè)置.線的寬可能還受到指定在當(dāng)前活躍的圖形上下文的變換矩陣中的縮放因素所影響.

The default line width is 1.0.
默認(rèn)的路徑寬度是1.0.

作用范圍(Availability):
Available in iOS 3.2 and later.

lineCapStyleProperty
The shape of the paths end points when stroked. 當(dāng)指定為描邊(stroked)時(shí),路徑終點(diǎn)的形狀

描述(Declaration):
//Swift
var lineCapStyle: CGLineCap
//Objective-C
@property(nonatomic) CGLineCap lineCapStyle
論述(Discussion):
The line cap style is applied to the start and end points of any open subpaths. This property does not affect closed subpaths.
這個(gè)線帽(和鍵帽一詞聯(lián)系)類型是被應(yīng)用在任意的開放子路徑的開始和結(jié)束點(diǎn)的.這個(gè)屬性不影響閉合子路徑.

The default line cap style is kCGLineCapButt.
默認(rèn)線帽類型是kCGLineCapButt.

作用范圍(Availability):
Available in iOS 3.2 and later.

lineJoinStyleProperty
The shape of the joints between connected segments of a stroked path.
一個(gè)描邊路徑的介于兩個(gè)關(guān)聯(lián)線段的連接處的形狀.

描述(Declaration):
//Swift
var lineJoinStyle: CGLineJoin
//Objective-C
@property(nonatomic) CGLineJoin lineJoinStyle
論述(Discussion):
The default line join style is kCGLineJoinMiter.
默認(rèn)的線連接處類型是kCGLineJoinMiter.

作用范圍(Availability):
Available in iOS 3.2 and later.

miterLimitProperty
The limiting value that helps avoid spikes at junctions between connected line segments.
這個(gè)限制的值幫助避免已連接線段之間的聯(lián)結(jié)點(diǎn)處的峰值.

描述(Declaration):
//Swift
var miterLimit: CGFloat
//Objective-C
@property(nonatomic) CGFloat miterLimit
論述(Discussion):
The miter limit helps you avoid spikes in paths that use the kCGLineJoinMiter join style. If the ratio of the miter length—that is, the diagonal length of the miter join—to the line thickness exceeds the miter limit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion of miters whose angle at the joint is less than 11 degrees.
這個(gè) ?斜接? 限制幫助你避免使用了kCGLineJoinMiter結(jié)點(diǎn)類型的路徑的峰值. 如果這個(gè) 斜面 長度的比值, 斜面加入厚度的線的對角長度超過斜借接限制,該聯(lián)結(jié)處被轉(zhuǎn)成為一個(gè)斜面連接.默認(rèn)的?斜接? 限制是10,其導(dǎo)致斜面在聯(lián)結(jié)點(diǎn)處的角度在轉(zhuǎn)換過正中小于11度.
(這段有點(diǎn)抽..)

作用范圍(Availability):
Available in iOS 3.2 and later.

flatnessProperty
The factor that determines the rendering accuracy for curved path segments.
決定彎曲路徑線段的渲染精度的因素.

描述(Declaration):
//Swift
var flatness: CGFloat
//Objective-C
@property(nonatomic) CGFloat flatness
論述(Discussion):
The flatness value measures the largest permissible distance (measured in pixels) between a point on the true curve and a point on the rendered curve. Smaller values result in smoother curves but require more computation time. Larger values result in more jagged curves but are rendered much faster. The default flatness value is 0.6. 平整度(flatness)值測量出在真實(shí)曲線上的點(diǎn)和呈現(xiàn)出曲線的點(diǎn)之間的最大允許的距離(以像素為單位). 值越小得到的曲線越平滑但是同時(shí)需要系統(tǒng)計(jì)算的時(shí)間也就更多. 值越大得到的曲線的鋸齒狀越多但是渲染的速度會(huì)變得非常快.默認(rèn)的平整度(flatness)值是0.6.

In most cases, you should not change the flatness value. However, you might increase the flatness value temporarily to minimize the amount of time it takes to draw a shape temporarily (such as during scrolling).
在大多數(shù)情況下,你不應(yīng)該改變平面度的值.然而,你可能會(huì)暫時(shí)增大平整度(flatness)的值去減少臨時(shí)繪制一個(gè)圖形的時(shí)間量(比如在滾動(dòng)的時(shí)候).

作用范圍(Availability):
Available in iOS 3.2 and later.

usesEvenOddFillRuleProperty
A Boolean indicating whether the even-odd winding rule is in use for drawing paths. 應(yīng)用在繪制路徑上的 指示是否奇偶彎曲的規(guī)則 的一個(gè)布爾值.??? _

描述(Declaration):
//Swift
var usesEvenOddFillRule: Bool
//Objective-C
@property(nonatomic) BOOL usesEvenOddFillRule
論述(Discussion):
If YES, the path is filled using the even-odd rule. If NO, it is filled using the non-zero rule. Both rules are algorithms to determine which areas of a path to fill with the current fill color. A ray is drawn from a point inside a given region to a point anywhere outside the path’s bounds. The total number of crossed path lines (including implicit path lines) and the direction of each path line are then interpreted as follows:
如果是YES的話,

For the even-odd rule, if the total number of path crossings is odd, the point is considered to be inside the path and the corresponding region is filled. If the number of crossings is even, the point is considered to be outside the path and the region is not filled.
第一種偿渡,even-odd 臼寄,判斷某點(diǎn)在不在fill area,需要從這點(diǎn)起溜宽,向區(qū)域外某一點(diǎn)畫射線吉拳,如果射線和奇數(shù)條path相交,那么這點(diǎn)是在fill area适揉,反之留攒,不在。
參考來自此篇文章

For the non-zero rule, the crossing of a left-to-right path counts as +1 and the crossing of a right-to-left path counts as -1. If the sum of the crossings is nonzero, the point is considered to be inside the path and the corresponding region is filled. If the sum is 0, the point is outside the path and the region is not filled.
第二種嫉嘀,也是畫射線炼邀,根據(jù)path的順時(shí)針和逆時(shí)針個(gè)數(shù)計(jì)算,如果和不為0剪侮,就是在fill area拭宁,反之,不在票彪。
參考來自此篇文章

The default value of this property is NO. For more information about winding rules and how they are applied to subpaths, see Quartz 2D Programming Guide.
這個(gè)屬性的默認(rèn)值是NO.對于更多和彎曲的規(guī)則和如何在子路徑上應(yīng)用,請參閱Quartz 2D Programming Guide.

作用范圍(Availability):
Available in iOS 3.2 and later.

  • setLineDash:count:phase:
    Sets the line-stroking pattern for the path. 設(shè)置路徑中的描邊線條(line-stroking)的模式.

描述(Declaration):
//Swift
func setLineDash(_ pattern: UnsafePointer<CGFloat>,
count count: Int,
phase phase: CGFloat)
//Objective-C

  • (void)setLineDash:(const CGFloat *)pattern
    count:(NSInteger)count
    phase:(CGFloat)phase
    參數(shù)(Parameters):
    pattern A C-style array of floating point values that contains the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
    count The number of values in pattern.
    phase The offset at which to start drawing the pattern, measured in points along the dashed-line pattern. For example, a phase value of 6 for the pattern 5-2-3-2 would cause drawing to begin in the middle of the first gap.
    pattern 在這個(gè)模式里,一組 C-樣式 的浮點(diǎn)值包含了線段和間隙的長度(用點(diǎn)來作計(jì)算). 數(shù)組中的值交替,是開始于第一個(gè)線段的長度,其次是第一個(gè) 間隙?? 長度,接著是從第二個(gè)線段的長度,以此類推.
    count 處在patter中值的數(shù)量.
    phase 在開始繪制這個(gè)模式時(shí)候的偏移量,是以虛線(dashed-line)模式上的點(diǎn)來測量的.舉個(gè)例子, 對于5-2-3-2模式的相位值是6的話,會(huì)導(dǎo)致從第一個(gè)間隙的中間開始繪制.
    作用范圍(Availability):
    Available in iOS 3.2 and later.

  • getLineDash:count:phase:
    Retrieves the line-stroking pattern for the path.
    獲取路徑中的線條筆畫(line-stroking)模式.

描述(Declaration):
//Swift
func getLineDash(_ pattern: UnsafeMutablePointer<CGFloat>,
count count: UnsafeMutablePointer<Int>,
phase phase: UnsafeMutablePointer<CGFloat>)
//Objective-C

  • (void)getLineDash:(CGFloat *)pattern
    count:(NSInteger *)count
    phase:(CGFloat *)phase
    參數(shù)(Parameters):
    pattern On input, a C-style array of floating point values, or nil if you do not want the pattern values. On output, this array contains the lengths (measured in points) of the line segments and gaps in the pattern. The values in the array alternate, starting with the first line segment length, followed by the first gap length, followed by the second line segment length, and so on.
    count On input, a pointer to an integer or nil if you do not want the number of pattern entries. On output, the number of entries written to pattern.
    phase On input, a pointer to a floating point value or nil if you do not want the phase. On output, this value contains the offset at which to start drawing the pattern, measured in points along the dashed-line pattern. For example, a phase of 6 in the pattern 5-2-3-2 would cause drawing to begin in the middle of the first gap.
    pattern 在輸入端,可以填入一組 C-樣式的浮點(diǎn)值,或者如果你不想要這個(gè)模式的值得話就填 nil.在輸出端,這個(gè)數(shù)組包含了在模式中的線段和間隙的長度(按點(diǎn)來測量).在數(shù)組中的值交替,最先從第一條線段的長度開始,其次從第一個(gè)間隙的長度,接著從第二條線段的長度,以此類推.
    count 在輸入端,一個(gè)指針指向一個(gè)整數(shù)或者 如果你不想模式條目的數(shù)量(讓其指向)nil. 在輸出端,寫入pattern的條目的數(shù)目.
    phase 在輸入端,一個(gè)指針指向一個(gè)浮點(diǎn)值或者如果你不想要這個(gè)階段(phase)的話(可以讓其指向)nil.在輸出端, 這個(gè)值包含開始繪制模式的偏移量,并且按沿著虛線(dashed-line)模式的點(diǎn)測量.舉個(gè)例子,5-2-3-2模式中的一個(gè)段6將導(dǎo)致從第一個(gè)間隙的中點(diǎn)開始繪制.
    論述(Discussion):
    The array in the pattern parameter must be large enough to hold all of the returned values in the pattern. If you are not sure how many values there might be, you can call this method twice. The first time you call it, do not pass a value for pattern but use the returned value in the count parameter to allocate an array of floating-point numbers that you can then pass in the second time.
    參數(shù)pattern中的數(shù)組必須足夠大去囊括在模式中的所有返回值.如果你不確定返回值的數(shù)量,你可以調(diào)用這個(gè)方法兩次.第一次你調(diào)用它的時(shí)候,不用給pattern賦值,但是用參數(shù)count的返回值分配給浮點(diǎn)數(shù)組,可以在你第二次調(diào)用這個(gè)方法的時(shí)候用.

作用范圍(Availability):
Available in iOS 3.2 and later.

Drawing Paths
繪制路徑

  • fill
    Paints the region enclosed by the receiver’s path using the current drawing properties.
    涂抹一個(gè)區(qū)域,這個(gè)區(qū)域被方法接收者的路徑用當(dāng)前的繪制屬性閉合的.

描述(Declaration):
//Swift
func fill()
//Objective-C

  • (void)fill
    論述(Discussion):
    This method fills the path using the current fill color and drawing properties. If the path contains any open subpaths, this method implicitly closes them before painting the fill region.
    這個(gè)方法用當(dāng)前填充顏色和正在繪制的屬性來填充路徑.如果這個(gè)路徑包含任何開放子路徑,那么這個(gè)路徑會(huì)在涂抹這個(gè)填充區(qū)域之前立即關(guān)閉它們.

The painted region includes the pixels right up to, but not including, the path line itself. For paths with large line widths, this can result in overlap between the fill region and the stroked path (which is itself centered on the path line). 已經(jīng)涂抹完的區(qū)域包括像素到右邊????, 但是不包括這個(gè)路徑線本身.對于線的寬度很大的路徑, 它能影響在填充區(qū)域和描邊路徑(自身集中在路徑線上)之間.

This method automatically saves the current graphics state prior to drawing and restores that state when it is done, so you do not have to save the graphics state yourself.
這個(gè)方法會(huì)在繪制之前自動(dòng)保存當(dāng)前圖形上下文狀態(tài),同時(shí)當(dāng)繪制完成之后恢復(fù)該狀態(tài),所以你自己不必保存圖形上狀態(tài).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • fillWithBlendMode:alpha:
    Paints the region enclosed by the receiver’s path using the specified blend mode and transparency values.
    用指定的混合模式和透明度值涂抹被方法接收者的路徑閉合的區(qū)域.

描述(Declaration):
//Swift
func fillWithBlendMode(_ blendMode: CGBlendMode,
alpha alpha: CGFloat)
//Objective-C

  • (void)fillWithBlendMode:(CGBlendMode)blendMode
    alpha:(CGFloat)alpha
    參數(shù)(Parameters):
    blendMode The blend mode determines how the filled path is composited with any existing rendered content.
    alpha The amount of transparency to apply to the filled path. Values can range between 0.0 (transparent) and 1.0 (opaque). Values outside this range are clamped to 0.0 or 1.0.
    blendMode 混合模式用來確定如何用任意現(xiàn)有的已經(jīng)渲染的內(nèi)容合成描邊路徑.
    alpha 應(yīng)用在描邊路徑上的透明度的值.取值范圍是0.0(透明)到1.0(不透明)之間. 邊界值是0.0或者1.0.
    論述(Discussion):
    This method fills the path using the current fill color and drawing properties (plus the specified blend mode and transparency value). If the path contains any open subpaths, this method implicitly closes them before painting the fill region.
    這個(gè)方法用當(dāng)前填充顏色和正在繪制屬性(加上指定的混合屬性和透明度值)填充路徑.如果這個(gè)路徑包含任意子路徑,那么這個(gè)方法會(huì)在涂抹這個(gè)填充區(qū)域之前立即關(guān)閉他們.

The painted region includes the pixels right up to, but not including, the path line itself. For paths with large line widths, this can result in between the fill region and the stroked path (which is itself centered on the path line). 已經(jīng)涂抹完的區(qū)域包括像素到右邊????, 但是不包括這個(gè)路徑線本身.對于線的寬度很大的路徑, 它能影響在填充區(qū)域和描邊路徑(自身集中在路徑線上)之間.

This method automatically saves the current graphics state prior to drawing and restores that state when it is done, so you do not have to save the graphics state yourself.
這個(gè)方法會(huì)在繪制之前自動(dòng)保存當(dāng)前圖形上下文狀態(tài),同時(shí)當(dāng)繪制完成之后恢復(fù)該狀態(tài),所以你自己不必保存圖形上狀態(tài).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • stroke
    Draws a line along the receiver’s path using the current drawing properties.
    用當(dāng)前的繪制屬性繪制一條沿著方法接收者路徑的線.

描述(Declaration):
//Swift
func stroke()
//Objective-C

  • (void)stroke
    論述(Discussion):
    The drawn line is centered on the path with its sides parallel to the path segment. This method applies the current drawing properties to the rendered path.
    繪制的線集中兩側(cè)平行于路徑段的路徑上.這個(gè)方法將當(dāng)前正在繪制的屬性應(yīng)用到可見的路徑上.

This method automatically saves the current graphics state prior to drawing and restores that state when it is done, so you do not have to save the graphics state yourself.
這個(gè)方法會(huì)在繪制之前自動(dòng)保存當(dāng)前圖形上下文狀態(tài),同時(shí)當(dāng)繪制完成之后恢復(fù)該狀態(tài),所以你自己不必保存圖形上狀態(tài).

作用范圍(Availability):
Available in iOS 3.2 and later.

  • strokeWithBlendMode:alpha:
    Draws a line along the receiver’s path using the specified blend mode and transparency values.
    使用指定的混合類型和透明度值沿著方法接收者的路徑畫一條線.

描述(Declaration):
//Swift
func strokeWithBlendMode(_ blendMode: CGBlendMode,
alpha alpha: CGFloat)
//Objective-C

  • (void)strokeWithBlendMode:(CGBlendMode)blendMode
    alpha:(CGFloat)alpha
    參數(shù)(Parameters):
    blendMode The blend mode determines how the stroked path is composited with any existing rendered content.
    alpha The amount of transparency to apply to the stroked path. Values can range between 0.0 (transparent) and 1.0 (opaque). Values outside this range are clamped to 0.0 or 1.0.
    blendMode 混合模式用來確定如何用任意現(xiàn)有的已經(jīng)渲染的內(nèi)容合成描邊路徑.
    alpha 應(yīng)用在描邊路徑上的透明度的值.取值范圍是0.0(透明)到1.0(不透明)之間. 邊界值是0.0或者1.0.
    論述(Discussion):
    The drawn line is centered on the path with its sides parallel to the path segment. This method applies the current stroke color and drawing properties (plus the specified blend mode and transparency value) to the rendered path.
    繪制的線集中兩側(cè)平行于路徑段的路徑上.這個(gè)方法吧當(dāng)前的描邊顏色和正在繪制的屬性(加上指定的混合模式和透明度值)應(yīng)用到渲染的路徑上.

This method automatically saves the current graphics state prior to drawing and restores that state when it is done, so you do not have to save the graphics state yourself.
這個(gè)方法會(huì)在繪制之前自動(dòng)保存當(dāng)前圖形上下文狀態(tài),同時(shí)當(dāng)繪制完成之后恢復(fù)該狀態(tài),所以你自己不必保存圖形上狀態(tài).

作用范圍(Availability):
Available in iOS 3.2 and later.

Clipping Paths

  • addClip
    Intersects the area enclosed by the receiver’s path with the clipping path of the current graphics context and makes the resulting shape the current clipping path.

交叉區(qū)域被方法接收者的路徑閉合,這個(gè)路徑用當(dāng)前圖形上下文的剪裁路徑,并且使結(jié)果圖形是當(dāng)前的裁剪路徑.

描述(Declaration):
//Swift
func addClip()
//Objective-C

  • (void)addClip
    論述(Discussion):
    This method modifies the visible drawing area of the current graphics context. After calling it, subsequent drawing operations result in rendered content only if they occur within the fill area of the specified path.
    這個(gè)方法更新了當(dāng)前圖形上下文下的可見繪制區(qū)域.當(dāng)調(diào)用了這個(gè)方法之后,隨后的繪制操作使得已經(jīng)渲染的內(nèi)容只有發(fā)生在它們指定路徑的填充區(qū)域內(nèi).

IMPORTANT
If you need to remove the clipping region to perform subsequent drawing operations, you must save the current graphics state (using the CGContextSaveGState function) before calling this method. When you no longer need the clipping region, you can then restore the previous drawing properties and clipping region using the CGContextRestoreGState function.

重要
如果你需要移除正在裁剪的區(qū)域然后執(zhí)行隨后的繪制操作,那么在調(diào)用這個(gè)方法之前,你必須保存當(dāng)前的圖形上下文的狀態(tài)(使用CGContextSaveGState方法).當(dāng)你不再需要這個(gè)裁剪區(qū)域的時(shí), _然后? 你可以恢復(fù)以前的繪制屬性
同時(shí) 裁剪區(qū)域使用CGContextRestoreGState方法.
The usesEvenOddFillRule property is used to determine whether the even-odd or non-zero rule is used to determine the area enclosed by the path. usesEvenOddFillRule被用來確定是否為奇偶(even-odd),或者用作確定被路徑閉合區(qū)域的非零(non-zero)規(guī)則.

作用范圍(Availability):
Available in iOS 3.2 and later.

Hit Detection
碰撞檢測

  • containsPoint:
    Returns a Boolean value indicating whether the area enclosed by the receiver contains the specified point.
    返回一個(gè)布爾值指示方法接受者閉合的區(qū)域是否包含的指定點(diǎn).

描述(Declaration):
//Swift
func containsPoint(_ point: CGPoint) -> Bool
//Objective-C

  • (BOOL)containsPoint:(CGPoint)point
    參數(shù)(Parameters):
    point | The point to test against the path, specified in the path object's coordinate system.

point | 測試在 指定的路徑對象的坐標(biāo)系中,.

返回值(Return Value):
YES if the point is considered to be within the path’s enclosed area or NO if it is not.
如果點(diǎn)被哦按段在路徑閉合的區(qū)域,那么返回值為YES.反之,則為 NO.

論述(Discussion):
The receiver contains the specified point if that point is in a portion of a closed subpath that would normally be painted during a fill operation. This method uses the value of the usesEvenOddFillRule property to determine which parts of the subpath would be filled.
方法接收者包含一個(gè)指定的點(diǎn),如果這個(gè)點(diǎn)事在一個(gè)封閉子路徑上,那么這個(gè)點(diǎn)在一個(gè)填充操作的時(shí)候通常會(huì)被繪制. 這個(gè)方法使用屬性usesEvenOddFillRule 的值來判斷子路徑的哪一部分將被填充.

A point is not considered to be enclosed by the path if it is inside an open subpath, regardless of whether that area would be painted during a fill operation. Therefore, to determine mouse hits on open paths, you must create a copy of the path object and explicitly close any subpaths (using the closePath method) before calling this method.
一個(gè)點(diǎn) 如果路徑它是里邊是開放子路徑,不管是否該區(qū)域在執(zhí)行填充操作,都是不被判定在圍住的范圍之內(nèi)的.因此,為了判斷在開放路徑中的鼠標(biāo)點(diǎn)擊,你必須在調(diào)用這個(gè)方法之前,創(chuàng)建一個(gè)路徑對象的拷貝和明確地關(guān)閉任何子路徑(使用closePath方法)

作用范圍(Availability):
Available in iOS 3.2 and later.

emptyProperty
A Boolean value indicating whether the path has any valid elements. (read-only)
一個(gè)布爾值,指示一個(gè)路徑是否有任何有效結(jié)元素(只讀).

描述(Declaration):
//Swift
var empty: Bool { get }
//Objective-C
@property(readonly, getter=isEmpty) BOOL empty
論述(Discussion):
Valid path elements include commands to move to a specified point, draw a line or curve segment, or close the path. Thus, a path is not considered empty even if all you do is call the moveToPoint: method.
有效的路徑元素包括移動(dòng)到一個(gè)指定點(diǎn)的命令,繪制一條線或者曲線,或者關(guān)閉路徑.因此,一條路徑即使你做的是調(diào)用moveTioPoint方法也是不會(huì)被判定為空的.

作用范圍(Availability):

Available in iOS 3.2 and later.

boundsProperty

The bounding rectangle of the path. (read-only)
路徑的矩形邊界(只讀)

描述(Declaration):

//Swift
var bounds: CGRect { get }
//Objective-C
@property(nonatomic, readonly) CGRect bounds

論述(Discussion):

The value in this property represents the smallest rectangle that completely encloses all points in the path, including any control points for Bézier and quadratic curves.
這個(gè)屬性的值表示完全 包含路徑上所有點(diǎn),包括任意貝塞爾曲線和二次曲線的控制點(diǎn)的 最小的矩形.

作用范圍(Availability):

Available in iOS 3.2 and later.

Applying Transformations

  • applyTransform:
    Transforms all points in the path using the specified affine transform matrix.
    用 仿射變換矩陣(the specified affine transform matrix) 改變所有在路徑上的點(diǎn).

描述(Declaration):

//Swift
func applyTransform(_ transform: CGAffineTransform)
//Objective-C
- (void)applyTransform:(CGAffineTransform)transform

參數(shù)(Parameters):

transform | The transform matrix to apply to the path.
transform | 應(yīng)用在路徑上變換矩陣.

論述(Discussion):

This method applies the specified transform to the path’s points immediately. The modifications made to the path object are permanent. If you do not want to permanently modify a path object, you should consider applying the transform to a copy.
這個(gè)方法立即把指定的改變應(yīng)用到路徑的點(diǎn)上.這個(gè)作用在路徑對象上的更新是永久性的.如果你想要永久的更新一個(gè)路徑對象,那么你應(yīng)該考慮把這個(gè)改變做一個(gè)備份.

作用范圍(Availability):

Available in iOS 3.2 and later.

Constants

UIRectCorner
The corners of a rectangle.
一個(gè)矩形的四個(gè)角.

描述(Declaration):

//Swift
struct UIRectCorner : OptionSetType {
init(rawValue rawValue: UInt)
static var TopLeft: UIRectCorner { get }
static var TopRight: UIRectCorner { get }
static var BottomLeft: UIRectCorner { get }
static var BottomRight: UIRectCorner { get }
static var AllCorners: UIRectCorner { get }
}
//Objective-C
enum {
   UIRectCornerTopLeft     = 1 << 0,
   UIRectCornerTopRight    = 1 << 1,
   UIRectCornerBottomLeft  = 1 << 2,
   UIRectCornerBottomRight = 1 << 3,
   UIRectCornerAllCorners  = ~0
};
typedef NSUInteger UIRectCorner;

常數(shù)(Constants):

  • UIRectCornerTopLeft
    The top-left corner of the rectangle.
    矩形的左上角.
    Available in iOS 3.2 and later.

  • UIRectCornerTopRight
    The top-right corner of the rectangle.
    矩形的右上角.
    Available in iOS 3.2 and later.

  • UIRectCornerBottomLeft
    The bottom-left corner of the rectangle.
    矩形的左下角.
    Available in iOS 3.2 and later.

  • UIRectCornerBottomRight
    The bottom-right corner of the rectangle.
    矩形的右下角.
    Available in iOS 3.2 and later.

  • UIRectCornerAllCorners
    All corners of the rectangle.
    矩形的所有的角.
    Available in iOS 3.2 and later.

論述(Discussion):
The specified constants reflect the corners of a rectangle that has not been modified by an affine transform and is drawn in the default coordinate system (where the origin is in the upper-left corner and positive values extend down and to the right).
指定的常數(shù)反映了一個(gè)沒有被仿射變換修改和已經(jīng)在默認(rèn)坐標(biāo)系上繪制的矩形的所有角.(原點(diǎn)在左上角和 擴(kuò)散的值(positive values) 向下延伸到右邊).

導(dǎo)入聲明(Import Statement)

//Swift
import UIKit
//Objective-C
@import UIKit;

作用范圍(Availability):

Available in iOS 3.2 and later.

Copyright ? 2016 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2012-09-19

原文:http://www.reibang.com/p/39f26d7c2aec

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末红淡,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子降铸,更是在濱河造成了極大的恐慌在旱,老刑警劉巖,帶你破解...
    沈念sama閱讀 206,013評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件推掸,死亡現(xiàn)場離奇詭異桶蝎,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)谅畅,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,205評論 2 382
  • 文/潘曉璐 我一進(jìn)店門登渣,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人毡泻,你說我怎么就攤上這事胜茧。” “怎么了仇味?”我有些...
    開封第一講書人閱讀 152,370評論 0 342
  • 文/不壞的土叔 我叫張陵呻顽,是天一觀的道長。 經(jīng)常有香客問我丹墨,道長廊遍,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,168評論 1 278
  • 正文 為了忘掉前任贩挣,我火速辦了婚禮喉前,結(jié)果婚禮上没酣,老公的妹妹穿的比我還像新娘。我一直安慰自己卵迂,他們只是感情好裕便,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,153評論 5 371
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著狭握,像睡著了一般闪金。 火紅的嫁衣襯著肌膚如雪疯溺。 梳的紋絲不亂的頭發(fā)上论颅,一...
    開封第一講書人閱讀 48,954評論 1 283
  • 那天,我揣著相機(jī)與錄音囱嫩,去河邊找鬼恃疯。 笑死,一個(gè)胖子當(dāng)著我的面吹牛墨闲,可吹牛的內(nèi)容都是我干的今妄。 我是一名探鬼主播,決...
    沈念sama閱讀 38,271評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼鸳碧,長吁一口氣:“原來是場噩夢啊……” “哼盾鳞!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起瞻离,我...
    開封第一講書人閱讀 36,916評論 0 259
  • 序言:老撾萬榮一對情侶失蹤腾仅,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后套利,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體推励,經(jīng)...
    沈念sama閱讀 43,382評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,877評論 2 323
  • 正文 我和宋清朗相戀三年肉迫,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了验辞。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 37,989評論 1 333
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡喊衫,死狀恐怖跌造,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情族购,我是刑警寧澤壳贪,帶...
    沈念sama閱讀 33,624評論 4 322
  • 正文 年R本政府宣布,位于F島的核電站联四,受9級特大地震影響撑碴,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜朝墩,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,209評論 3 307
  • 文/蒙蒙 一醉拓、第九天 我趴在偏房一處隱蔽的房頂上張望伟姐。 院中可真熱鬧,春花似錦亿卤、人聲如沸愤兵。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,199評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽秆乳。三九已至,卻和暖如春钻哩,著一層夾襖步出監(jiān)牢的瞬間屹堰,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,418評論 1 260
  • 我被黑心中介騙來泰國打工街氢, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留扯键,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 45,401評論 2 352
  • 正文 我出身青樓珊肃,卻偏偏與公主長得像荣刑,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子伦乔,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,700評論 2 345

推薦閱讀更多精彩內(nèi)容