UIBezierPath類

UIBezierPath Class Reference

譯:UIBezierPath類
封裝了Core Graphics(純C語言框架)的Objective—C類诈豌,不能實現(xiàn)陰影和漸變效果萝究,要實現(xiàn)的話還得用純C的Core Graphics框架杭隙。
翻譯于2016年9月28日莱坎,第一版內(nèi)容未校驗


注解:貝塞爾曲線(Bézier curve)盐肃,又稱貝茲曲線或貝濟埃曲線俯艰,是應用于二維圖形應用程序的數(shù)學曲線盒犹。一般的矢量圖形軟件通過它來精確畫出曲線懂更,貝茲曲線由線段與節(jié)點組成眨业,節(jié)點是可拖動的支點,線段像可伸縮的皮筋沮协,我們在繪圖工具上看到的鋼筆工具就是來做這種矢量曲線的龄捡。貝塞爾曲線是計算機圖形學中相當重要的參數(shù)曲線,貝塞爾曲線于1962慷暂,由法國工程師皮埃爾·貝塞爾(Pierre Bézier)所廣泛發(fā)表聘殖,他運用貝塞爾曲線來為汽車的主體進行設(shè)計。貝塞爾曲線最初由Paul de Casteljau于1959年運用de Casteljau演算法開發(fā)行瑞,以穩(wěn)定數(shù)值的方法求出貝茲曲線奸腺。
貝塞爾曲線就是這樣的一條曲線,它是依據(jù)四個位置任意的點坐標繪制出的一條光滑曲線血久。在歷史上突照,研究貝塞爾曲線的人最初是按照已知曲線參數(shù)方程來確定四個點的思路設(shè)計出這種矢量曲線繪制法。貝塞爾曲線的有趣之處更在于它的“皮筋效應”氧吐,也就是說讹蘑,隨著點有規(guī)律地移動,曲線將產(chǎn)生皮筋伸引一樣的變換筑舅,帶來視覺上的沖擊座慰。1962年,法國數(shù)學家Pierre Bézier第一個研究了這種矢量繪制曲線的方法豁翎,并給出了詳細的計算公式角骤,因此按照這樣的公式繪制出來的曲線就用他的姓氏來命名是為貝塞爾曲線。

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類允許您定義一個由直線和曲線段組成的路徑和在您的自定義視圖上渲染路徑心剥。你使用這個類首先指定你的幾何路徑邦尊。路徑可以定義簡單的形狀如矩形、橢圓优烧、弧或可以把直線和曲線段混合成復合多邊形蝉揍。定義形狀后,你可以使用這個類的添加方法將路徑添加在當前繪圖上下文進行渲染。

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, Bezierpath 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.

譯:UIBezierPath對象結(jié)合了幾何路徑及其如何渲染屬性畦娄。你分別設(shè)置幾何結(jié)構(gòu)和屬性,可以互相獨立地改變他們又沾。一旦你有了所希望方式配置的對象,你可以告訴它在當前上下文中繪畫出本身。因為創(chuàng)建熙卡、配置和渲染過程都是不同階段,Bezierpath對象可以簡單地重用你的代碼杖刷。您甚至可以使用同一個對象去渲染同一個形狀多次,或許在改變渲染選項和連續(xù)繪畫之間調(diào)用同一個Bezierpath對象。

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 arestarting 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.

譯:您通過操作路徑的當前點來設(shè)置幾何路徑驳癌。當您創(chuàng)建一個新的空path對象,當前點是未定義的,必須顯式地設(shè)置滑燃。您使用moveToPoint:方法來移到當前點而不會畫線段。所有其他方法產(chǎn)生不適添加直線就是曲線段到路徑颓鲜。添加新線段方法總是假設(shè)你在當前點和您指定的結(jié)束點表窘。在添加線段之后,新線段的終點自動成為當前點典予。

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.

譯:一個Bezier曲線路徑對象可以包含任意數(shù)量的開放或封閉的子路徑,其中每個子路徑都是相連的路徑段。調(diào)用closePath方法添加一條從當前點到首發(fā)點的直線段關(guān)閉子路徑乐严。調(diào)用moveToPoint:方法結(jié)束當前的子路徑(沒有關(guān)閉)和然后設(shè)置下一子路徑起始點瘤袖。Bezier曲線路徑的子路徑對象共享相同的屬性和必須作為一個整體操作。畫不同的屬性的子路徑,你必須將每一個子路徑放到它自己的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.)

譯:配置Bezier曲線路徑的幾何特性和屬性之后,你使用描邊和填充方法將路徑畫在當前圖形上下文捂敌。stroke方法使用當前stroke顏色和Bezier曲線路徑對象的屬性描繪路徑的輪廓。同樣,fill方法使用當前的填充顏色填充封閉的路徑凛篙。(你使用UIColor類設(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.

譯:除了使用Bezier曲線路徑對象去畫形狀,您還可以使用它來定義一個新的剪裁區(qū)域。addClip方法描寫路徑對象與當前圖形上下文裁剪區(qū)域的交叉形狀呛梆。在隨后繪畫,實際上只有在新的交叉區(qū)域線的內(nèi)容呈現(xiàn)給圖形上下文锐涯。

Creating a UIBezierPath Object

譯:創(chuàng)建一個UIBezierPath對象

+ bezierPath

Creates and returns a new UIBezierPath object.

譯:創(chuàng)建和返回一個UIBezierPath對象

Declaration

譯:聲明

<code>
OBJECTIVE-C
+ (instancetype)bezierPath
</code>

Return Value

A new empty path object. ->一個新的空的path對象

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


+ bezierPathWithRect:
Creates and returns a new UIBezierPath object initialized with a rectangular path.

譯:創(chuàng)建并返回一個新的初始化為矩形的UIBezierPath對象.

Declaration

譯:聲明

<code>
SWIFT
convenience->便利構(gòu)造方法: init(rect rect: CGRect)
</code>
<code>
OBJECTIVE-C
+ (instancetype)bezierPathWithRect:(CGRect)rect
Parameters
rect |The rectangle describing the path to create.->創(chuàng)建描述矩形的路徑
</code>

Return Value

A new path object with the rectangular path.->一個矩形新路徑對象

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).->這個方法通過在矩形的原點開始順時針方向添加線段創(chuàng)建一個封閉的子路徑,(相對于默認坐標系)

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


+ bezierPathWithOvalInRect:

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

譯:創(chuàng)建并返回一個初始化指定內(nèi)切矩形的橢圓形的新UIBezierPath對像路徑。

Declaration

譯:聲明

<code>
SWIFT
convenience->便利構(gòu)造函數(shù): init(ovalInRect rect: CGRect)
OBJECTIVE-C
+ (instancetype)bezierPathWithOvalInRect:(CGRect)rect
Parameters
rect |The rectangle in which to inscribe an oval.->內(nèi)切橢圓形的矩形
</code>

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.->這個方法使用一系列?貝塞爾曲線數(shù)列創(chuàng)建一個近似于橢圓形的封閉子路徑填物。這是一個順時針方向創(chuàng)建的路徑(相對于默認坐標系)纹腌。如果rect參數(shù)指定了一個方形,內(nèi)切路徑是一個圓。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


+ bezierPathWithRoundedRect:cornerRadius:

Creates and returns a new UIBezierPath object initialized with a rounded rectangular path.

譯:創(chuàng)建并返回一個新的初始化一個圓角矩形UIBezierPath對象路徑滞磺。

Declaration

譯:聲明

<code>
SWIFT
convenience->便利構(gòu)造函數(shù): init(roundedRect rect: CGRect,
cornerRadius cornerRadius: CGFloat)
OBJECTIVE-C
+ (instancetype)bezierPathWithRoundedRect:(CGRect)rect
cornerRadius:(CGFloat)cornerRadius
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.->每一個角落橢圓的半徑升薯。值為0時為一個沒有圓角的矩形。值超過矩形的寬度或高度一半時击困,強制為寬度或高度的一半涎劈。
</code>

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.->這個方法沿順時針方向創(chuàng)建一個帶必要的直線和曲線段的封閉子路徑(相對于默認坐標系統(tǒng))

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


+ bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:

Creates and returns a new UIBezierPath object initialized with a rounded rectangular path.

譯:創(chuàng)建并返回一個新的初始化為一個圓角矩形UIBezierPath路徑對象阅茶。

Declaration

譯:聲明

<code>
SWIFT
convenience->便利構(gòu)造函數(shù): init(roundedRect rect: CGRect,
byRoundingCorners corners: UIRectCorner,
cornerRadii cornerRadii: CGSize)
OBJECTIVE-C
+ (instancetype)bezierPathWithRoundedRect:(CGRect)rect
byRoundingCorners:(UIRectCorner)corners
cornerRadii:(CGSize)cornerRadii
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.->你想要的圓角的位掩碼值。你可以使用這個參數(shù)去只將矩形一個角進行倒角脸哀。
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.->每一個角的的橢圓半徑蹦浦。值大于矩形的寬度或?qū)挾纫话霑r,強制為寬度或高度的一半撞蜂。
</code>

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.->這個方法沿順時針方向創(chuàng)建一個必要的直線和曲線段的封閉子路徑,(相對于默認坐標系統(tǒng)),。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


+ bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:

Creates and returns a new UIBezierPath object initialized with an arc of a circle.

譯:創(chuàng)建并返回一個初始化一個圓弧的新UIBezierPath對象蝌诡。

Declaration

譯:聲明

<code>
SWIFT
convenience->便利構(gòu)造函數(shù): 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
Parameters
center | Specifies the center point of the circle (in the current coordinate system) used to definethe 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).->指定圓弧結(jié)束的角度(單位為弧度)顽照。
clockwise| The direction in which to draw the arc.->指定圓弧描繪的方向。
</code>

Return Value

A new path object with the specified arc.->一個指定弧度的新路徑對象

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 thesame start and end angles but setting the clockwise parameter set to NO draws the top half of the circle.->這個方法創(chuàng)建一個開放的子路徑闽寡。創(chuàng)建的圓弧位于指定圓的周長代兵。當在默認坐標系統(tǒng),開始和結(jié)束的角度是基于如圖1所示的坐標系。例如,指定一個開始角弧度為0,結(jié)束角弧度為π的圓弧,和設(shè)置clockwise參數(shù)為YES畫的是圓的下半部库继。然而設(shè)定clockwise為NO,畫的是圓的下半部笨农。

Figure 1 Angles in the default coordinate system

譯:圖1 在默認坐標系的角度

Snip20160927_1.png

After calling this method, the current point is set to the point on the arc at the end angle of the circle.->調(diào)用這個方法企垦,當前點設(shè)為圓弧圓周上終點。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


+ bezierPathWithCGPath:

Creates and returns a new UIBezierPath object initialized with the contents of a Core Graphics path.->創(chuàng)建并返回一個初始化為核心圖形內(nèi)容的新UIBezierPath對象路徑思币。

Declaration

譯:聲明

<code>
SWIFT
convenience->便利構(gòu)造函數(shù): init(CGPath CGPath: CGPath)
OBJECTIVE-C
+ (instancetype)bezierPathWithCGPath:(CGPathRef)CGPath
Parameters
CGPath | The Core Graphics path from which to obtain the initial path information. If this parameteris nil, the method raises an exception.->核心圖形的路徑獲得最初的路徑信息。如果這參數(shù)為nil,該方法提出了一個異常羡微。
</code>

Return Value

A new path object with the specified path information.->包含指定路徑信息的新路徑對象谷饿。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- bezierPathByReversingPath

Creates and returns a new bezier path object with the reversed contents of the current path.->創(chuàng)建并返回一個逆轉(zhuǎn)當前路徑內(nèi)容的新的bezier曲線路徑對象。

Declaration

譯:聲明

<code>
SWIFT
func bezierPathByReversingPath() -> UIBezierPath
OBJECTIVE-C
- (UIBezierPath *)bezierPathByReversingPath
</code>

Return Value

A new path object with the same path shape but for which the path has been created in the reverse direction.->創(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 counter clockwise 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.->扭轉(zhuǎn)了路徑渲染不一定改變路徑的外觀妈倔。相反,它改變了路徑片段繪畫方向博投。例如,扭轉(zhuǎn)一個矩形的路徑(其線段通常從原點開始反時針繪畫)導致其線段沿順時針方向繪畫。根據(jù)渲染模式和fill規(guī)則盯蝴,畫一個相反路徑會影響fill模式的外觀毅哗。
This method reverses each whole or partial subpath in the path object individually.->該方法分別改變路徑中的每個或全部子路徑對象

Availability

Available in iOS 6.0 and later.->iOS 6.0以后適用

Constructing a Path

譯:構(gòu)造路徑

- moveToPoint:
Moves the receiver’s current point to the specified location.->移動當前點到指定的位置

Declaration

譯:聲明

<code>
SWIFT
func moveToPoint(_ point: CGPoint)
OBJECTIVE-C
- (void)moveToPoint:(CGPoint)point
Parameters
point | A point in the current coordinate system.->在當前坐標系的一個點
</code>

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.->這種方法隱式結(jié)束當前的子路徑(如果有的話),并設(shè)置當前點指向參數(shù)中的點。結(jié)束上一個子路徑時,這種方法實際上并不關(guān)閉子路徑捧挺。因此,之前子路徑的第一個和最后一個點不是彼此連接的虑绵。
For many path operations, you must call this method before issuing any commands that cause a line orcurve segment to be drawn.->對于許多路徑操作,您要去畫一條線段前,必須調(diào)用這個方法闽烙。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- addLineToPoint:

Appends a straight line to the receiver’s path.->添加一條直線到路徑

Declaration

譯:聲明

<code>
SWIFT
func addLineToPoint(_ point: CGPoint)
OBJECTIVE-C
- (void)addLineToPoint:(CGPoint)point
Parameters
point | The destination point of the line segment, specified in the current coordinate system.->在當前的坐標系統(tǒng),指定一條的目標點的線段翅睛。
</code>

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.->這個方法創(chuàng)建了一條從當前開始點到這參數(shù)指定的終點的一條直線。添加線段后,這種方法更新當前點為參數(shù)指定的點黑竞。
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.->必須設(shè)置路徑的當前點(使用moveToPoint:方法或通過前面直線或曲線段的創(chuàng)建)在你調(diào)用這個方法捕发。如果路徑是空的,這個方法并沒有做什么。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- addArcWithCenter:radius:startAngle:endAngle:clockwise:

Appends an arc to the receiver’s path.->添加一條圓弧到路徑

Declaration

譯:聲明

<code>
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
Parameters
center | Specifies the center point of the circle (in the current coordinate system) used to define the arc.->指定圓的中心點(在當前坐標系統(tǒng))用于定義圓弧摊溶。
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.->圓弧繪畫方向莫换。
</code>

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 basedon 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 tophalf of the circle.->這種方法在當前點開始增加指定的圓弧霞玄,創(chuàng)建的弧位位于指定圓形的周長。當在默認的坐標系統(tǒng),開始和結(jié)束的角度是圖1所示的基本圓形拉岁。例如,指定一個開始角度0弧度,結(jié)束角度為π弧度,設(shè)置順時針參數(shù)為YES坷剧,將畫圓的下半部分。然而,指定相同的開始和結(jié)束角度喊暖,但設(shè)置順時針參數(shù)設(shè)置為NO惫企,將畫圓形的下半部。
After calling this method, the current point is set to the point on the arc at the end angle of the circle.->調(diào)用這個方法后,當前點為圓弧周長的終點上狞尔。

Availability

Available in iOS 4.0 and later.->iOS 4.0以后適用


- addCurveToPoint:controlPoint1:controlPoint2:

Appends a cubic Bézier curve to the receiver’s path.->添加一條cubic貝塞爾曲線到路徑

Declaration

譯:聲明

<code>
SWIFT
func addCurveToPoint(_ endPoint: CGPoint,
controlPoint1 controlPoint1: CGPoint,
controlPoint2 controlPoint2: CGPoint)
OBJECTIVE-C
- (void)addCurveToPoint:(CGPoint)endPoint
controlPoint1:(CGPoint)controlPoint1
controlPoint2:(CGPoint)controlPoint2
Parameters
endPoint | The end point of the curve.->曲線終點
controlPoint1 | 用來計算曲線的第一個控制點
controlPoint2 | 用來計算曲線的第二個控制點
</code>

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.->這個方法添加一條從當前點到通過參數(shù)指定終點的cubic貝塞爾曲線丛版。這兩個控制點定義線段的曲率。圖2顯示了給定一組初始點計算出接近于cubic貝塞爾曲線偏序。精確曲率的曲線需要所有點復雜的數(shù)學運算页畦。

Figure 2 A cubic Bézier curve

譯:一條cubic貝塞爾曲線

Snip20160927_2.png

You must set the path’s current point (using the moveToPoint: method or through the previous creationof 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)用這個方法之前必須設(shè)置路徑的當前點(使用moveToPoint:方法或通過前面創(chuàng)建直線或曲線段方法)。如果路徑是空的,這個方法并沒有做些什么研儒。添加曲線段之后,這方法更新當前指向參數(shù)指定的終點豫缨。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- addQuadCurveToPoint:controlPoint:

Appends a quadratic Bézier curve to the receiver’s path.->添加一條2次方貝塞爾曲線到路徑

Declaration

譯:聲明

<code>
SWIFT
func addQuadCurveToPoint(_ endPoint: CGPoint,
controlPoint controlPoint: CGPoint)
OBJECTIVE-C
- (void)addQuadCurveToPoint:(CGPoint)endPoint
controlPoint:(CGPoint)controlPoint
Parameters
endPoint | The end point of the curve.->曲線終點
controlPoint | The control point of the curve.->曲線控制點
</code>

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.->這種方法從當前點到參數(shù)指定終點添加一條二次方貝塞爾曲線。當前點,曲率控制點,終點三個點之間的關(guān)系如圖3顯示了一些基于樣本點計算出二次方曲線示例端朵。精確曲率涉及到這些點之間復雜的數(shù)學計算好芭。
Figure 3 Quadratic curve examples

譯:2次方曲線樣本

Snip20160927_3.png

You must set the path’s current point (using the moveToPoint: method or through the previous creationof 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)用這個方法之前必須設(shè)置路徑的當前點(使用moveToPoint:方法或通過前面創(chuàng)建直線或曲線段方法)。如果路徑是空的,這個方法并沒有做些什么冲呢。添加曲線段之后,這方法更新當前指向參數(shù)指定的終點舍败。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- closePath
Closes the most recently added subpath.->關(guān)閉當前添加的子路徑

Declaration

譯:聲明

<code>
SWIFT
func closePath()
OBJECTIVE-C
- (void)closePath
</code>

Discussion

This method closes the current subpath by creating a line segment between the first and last points inthe 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.->這個方法創(chuàng)建一條從起始點到子路徑終點的線段關(guān)閉當前子路徑。這個方法從當前點創(chuàng)建一條線段到終點(也是起始點)關(guān)閉子路徑碗硬。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- removeAllPoints

Removes all points from the receiver, effectively deleting all subpaths.->從接受者刪除所有點瓤湘,有效地刪除所有子路徑。

Declaration

譯:聲明

<code>
SWIFT
func removeAllPoints()
OBJECTIVE-C
-(void)removeAllPoints
</code>

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- appendPath:

Appends the contents of the specified path object to the receiver’s path.->添加一條指定內(nèi)容的路徑到路徑對象中

Declaration

譯:聲明

<code>
SWIFT
func appendPath(_ bezierPath: UIBezierPath)
OBJECTIVE-C
- (void)appendPath:(UIBezierPath *)bezierPath
Parameters
bezierPath |The path to add to the receiver 添加路徑到接受者
</code>

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路徑添加到用于接收者的結(jié)束路徑恩尾。這種方法不明確嘗試連接在兩個物體的子路徑,盡管操作bezierPath路徑仍然會導致那樣的結(jié)果弛说。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


CGPath (Property/屬性)
The Core Graphics representation of the path.

譯:表示Core Graphics路徑

Declaration

譯:聲明

<code>
SWIFT
var CGPath: CGPath
OBJECTIVE-C
@property(nonatomic) CGPathRef CGPath
</code>

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.->這個屬性包含一個在任何給定的時間點上路徑快照的。讓這個屬性返回不可變的路徑對象,您可以通過Core Graphics函數(shù)使用翰意。路徑對象本身擁有UIBezierPath對象和直到您進一步修改路徑有效木人。

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.->你可以設(shè)置這個路徑的屬性值給你使用的Core Graphics框架函數(shù)使用。當設(shè)置一個新的路徑,這種方法使用您提供的路徑的副本冀偶。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用

currentPoint (Property/屬性)

The current point in the graphics path. (read-only)->圖形路徑當前點醒第。(只讀)

Declaration

譯:聲明

<code>
SWIFT
var currentPoint: CGPoint { get }
OBJECTIVE-C
@property(nonatomic, readonly) CGPoint currentPoint
</code>

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.->在這個屬性的值代表了新的線段和曲線段的起點。如果路徑當前為空,這個屬性包含CGPointZero值进鸠。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用
See Also
empty ->無

</br>

Accessing Drawing Properties

</br>
lineWidth (Property/屬性)

The line width of the path.->路徑線寬

Declaration

譯:聲明

<code>
SWIFT
var lineWidth: CGFloat
OBJECTIVE-C
@property(nonatomic) CGFloat lineWidth
</code>

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.->線寬定義了接收者描邊路徑的厚度稠曼。0線寬解釋為可以在特定設(shè)備上渲染最薄的線寬。實際渲染的線寬指定可能會有來自兩種設(shè)備像素,根據(jù)線的位置的像素網(wǎng)格和當前抗鋸齒而設(shè)置客年。線的寬度也可以擴展影響因素中指定當前活躍的圖形上下文的變換矩陣霞幅。
The default line width is 1.0.->默認線寬為1.0

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


lineCapStyle (Property/屬性)

The shape of the paths end points when stroked.->描邊路徑終點形狀

Declaration

譯:聲明

<code>
SWIFT
var lineCapStyle: CGLineCap
OBJECTIVE-C
@property(nonatomic) CGLineCap lineCapStyle
</code>

Discussion

The line cap style is applied to the start and end points of any open subpaths. This property does not affect closed subpaths. The default line cap style is kCGLineCapButt.->線帽風格應用于任何未關(guān)閉子路徑的開始點和結(jié)束點。這個屬性不會影響封閉的子路徑量瓜。默認的線帽風格是kCGLineCapButt司恳。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


lineJoinStyle (Property/屬性)

The shape of the joints between connected segments of a stroked path.->描邊的兩條線段連接點形狀

Declaration

譯:聲明

<code>
SWIFT
var lineJoinStyle: CGLineJoin
OBJECTIVE-C
@property(nonatomic) CGLineJoin lineJoinStyle
</code>

Discussion

The default line join style is kCGLineJoinMiter.->默認類型為kCGLineJoinMiter

Availability

Available in iOS 3.2 and later.iOS 3.2以后適用


miterLimit (Property/屬性)

The limiting value that helps avoid spikes at junctions between connected line segments.->有助于避免峰值的極限值連接線段間的連接。

Declaration

譯:聲明

<code>
SWIFT
var miterLimit: CGFloat
OBJECTIVE-C
@property(nonatomic) CGFloat miterLimit
</code>

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 miterlimit, the joint is converted to a bevel join. The default miter limit is 10, which results in the conversion ofmiters whose angle at the joint is less than 11 degrees.->加入kCGLineJoinMiter斜切割風格限制可以幫助你避免在路徑使用峰值绍傲。無法理解……&扔傅!……&……&#……@但設(shè)置后連接就好看了

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


flatness (Property/屬性)

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

Declaration

譯:聲明

<code>
SWIFT
var flatness: CGFloat
OBJECTIVE-C
@property(nonatomic) CGFloat flatness
</code>

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.->平面度值測量一個在真實曲線上的點與一個渲染曲線的點之間最大允許的距離(以像素為單位)。較小的值導致曲線平滑,但需要更多的計算時間猎塞。較大的值導致呈現(xiàn)更多鋸齒狀曲線,但渲染快得多试读。默認的平面度值為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ù)情況下,你不應該改變平面度值邢享。然而,你可能會增加平面度值暫時減少所花費的時間去暫時畫一個形狀(比如滑動時)鹏往。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


usesEvenOddFillRule (Property/屬性)

A Boolean indicating whether the even-odd winding rule is in use for drawing paths.->一個布爾值表示單雙數(shù)圈規(guī)則是否用于繪制路徑。

Declaration

譯:聲明

<code>
SWIFT
var usesEvenOddFillRule: Bool
OBJECTIVE-C
@property(nonatomic) BOOL usesEvenOddFillRule
</code>

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,使用單雙數(shù)規(guī)則填充路徑骇塘。如果為NO,使用非零的規(guī)則填充路徑。兩個規(guī)則都是用來確定哪一部分區(qū)域填充現(xiàn)在的填充顏色的算法韩容。畫一條射線從一個給定區(qū)域點到路徑范圍以外任意的一個點款违。交叉路徑線的總數(shù)(包括隱式路徑線)和每條路徑線的方向解析如下:

  • 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.->對于單雙數(shù)規(guī)則,如果路徑交叉的總數(shù)是奇數(shù),那點被認為在路徑里面,然后相應區(qū)域被填充群凶。如果路徑交叉的總數(shù)是偶數(shù),那點被認為在路徑外面插爹,然后相應區(qū)域不被填充。
  • 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.->對于非零的規(guī)則,從左到右穿越路徑數(shù)+ 1,從右到左穿越路徑數(shù)為-1请梢。如果穿越點的總和是非零,被認為是路徑內(nèi)部的點和填充相應的區(qū)域赠尾。如果穿越點的總和是零,被認為是路徑外部的點和不填充相應的區(qū)域。

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.->這個屬性的默認值是NO的毅弧。更多信息關(guān)于winding rules和它們是如何應用于子路徑,見Quartz 2D Programming Guide气嫁。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- setLineDash:count:phase:

Sets the line-stroking pattern for the path.->設(shè)置一排線段(虛線)模式的路徑。

Declaration

譯:聲明

<code>
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
</code>
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.->一系列包含線段和間隔長度(以點為單位)的c語言風格的浮點值模式够坐。數(shù)組中的值相互交替,從第一條線段長度,緊隨其后的是第一個間隔長度,緊隨其后的是第二個線段長度等等寸宵。
count | The number of values in pattern.->這種模式的數(shù)量
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.開始畫這種模式的偏移量,以點為單位的虛線模式。例如,phase值為6時元咙,會導致5-2-3-2模式從第一個缺口開始畫梯影。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- getLineDash:count:phase:

Retrieves the line-stroking pattern for the path.->得到一條一排線段(虛線)路徑

Declaration

譯:聲明

<code>
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
</code>
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.->輸入一系列C語言風格的浮點數(shù)或者當你不想要pattern值輸入nil。輸出一系列虛線的長度(以點為單位)庶香。這些值是相互交替的甲棍,從先線段開始,然后間隔赶掖,接著下一條線段等等感猛。
count | On output, the number of entries written to pattern.On input, a pointer to an integer or nil if you do not want the number of pattern entries.->輸出,寫入這模式條目數(shù)量。輸入,一個指向一個整數(shù)指針或如果你不想模式條目的數(shù)量輸入nil倘零。
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-2would cause drawing to begin in the middle of the first gap.->輸入,一個指向一個浮點值的指針或如果你不想要phase設(shè)為nil唱遭。對產(chǎn)出,這個值包含開始畫這模式的偏移量,以點為單位虛線模式。例如,phase為6呈驶,將導致模式5-2-3-2從第一個缺口開始畫拷泽。

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ù)的數(shù)組必須足夠容納所有的模式返回值。如果你不確定有多少價值,你可以調(diào)用這個方法兩次。第一次調(diào)用不通過pattern的模式但您可以通過在第二次司致,使用返回值的count參數(shù)來分配浮點數(shù)數(shù)組拆吆。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


Drawing Paths

- fill

Paints the region enclosed by the receiver’s path using the current drawing properties.->用當前繪圖屬性去涂接收者封閉路徑的范圍。

Declaration

譯:聲明

<code>
SWIFT
func fill()
OBJECTIVE-C
- (void)fill
</code>

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.->這個方法用當前填充顏色和繪圖屬性去填充路徑脂矫。如果路徑包含其他子路徑枣耀,這方法在填充范圍內(nèi)隱形關(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).->涂畫范圍包括那些像素,但不包括路徑本身庭再。帶線寬的路徑捞奕,這會導致填充區(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.->該方法自動保存當前圖形狀態(tài)狀態(tài)和恢復之前狀態(tài)拄轻。當它完成,你不需要自己保存圖形狀態(tài)颅围。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- fillWithBlendMode:alpha:

Paints the region enclosed by the receiver’s path using the specified blend mode and transparency values.->用指定的混合模式和透明度值去涂畫接受者路徑關(guān)閉區(qū)域

Declaration

譯:聲明

<code>
SWIFT
func fillWithBlendMode(_ blendMode: CGBlendMode,
alpha alpha: CGFloat)
OBJECTIVE-C
- (void)fillWithBlendMode:(CGBlendMode)blendMode
alpha:(CGFloat)alpha
</code>
Parameters
blendMode |The blend mode determines how the filled path is composited with any existing rendered content.->blend模式確定如何去填充當前渲染內(nèi)容的路徑。
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.->填充路徑的透明度恨搓。值的范圍在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.->這種方法使用當前填充顏色和填充路徑屬性(加上指定的混合模式和透明度值)填充路徑斧抱。如果路徑包含任何未關(guān)閉的子路徑,這種方法涂畫填充區(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).->涂畫范圍包括那些像素,但不包括路徑本身。帶線寬的路徑辉浦,這會導致填充區(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.->該方法自動保存當前圖形狀態(tài)狀態(tài)和恢復之前狀態(tài)。當它完成,你不需要自己保存圖形狀態(tài)盏浙。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- stroke

Draws a line along the receiver’s path using the current drawing properties.->用當前繪畫屬性畫用接收者路徑線路眉睹。

Declaration

譯:聲明

<code>
SWIFT
func stroke()
OBJECTIVE-C
- (void)stroke
</code>

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è)平行路徑段。這種方法適用于當前繪圖屬性去渲染路徑废膘。
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.->該方法自動保存當前圖形狀態(tài)狀態(tài)和恢復之前狀態(tài)竹海。當它完成,你不需要自己保存圖形狀態(tài)。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


- strokeWithBlendMode:alpha:

Draws a line along the receiver’s path using the specified blend mode and transparency values.用指定的blend模式和透明去去畫接收者路徑線路丐黄。

Declaration

譯:聲明

<code>
SWIFT
func strokeWithBlendMode(_ blendMode: CGBlendMode,
alpha alpha: CGFloat)
OBJECTIVE-C
- (void)strokeWithBlendMode:(CGBlendMode)blendMode
alpha:(CGFloat)alpha
</code>
Parameters
blendMode |The blend mode determines how the stroked path is composited with any existing rendered content.->blend模式確定如何去填充當前渲染內(nèi)容的路徑斋配。
alpha | The amount of transparency to apply to the stroked path. Values can range between0.0 (transparent) and 1.0 (opaque). Values outside this range are clamped to 0.0 or1.0.->填充路徑的透明度。值的范圍在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.->這種方法使用當前填充顏色和填充路徑屬性(加上指定的混合模式和透明度值)填充路徑。如果路徑包含任何未關(guān)閉的子路徑,這種方法涂畫填充區(qū)域前隱式地關(guān)閉桂对。
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.->->該方法自動保存當前圖形狀態(tài)狀態(tài)和恢復之前狀態(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.->當前圖像內(nèi)容和帶剪切路徑的接收者路徑相交的區(qū)域蕉斜,根據(jù)剪切路徑得到形狀逾柿。

Declaration

譯:聲明

<code>
SWIFT
func addClip()
OBJECTIVE-C
- (void)addClip
</code>

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.->這種方法修改當前圖形上下文的可見繪圖區(qū)域缀棍。調(diào)用它后,導致隨后的繪圖操作呈現(xiàn)內(nèi)容只發(fā)生在指定路徑的填充區(qū)域。

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.
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.->如果您需要執(zhí)行子路徑刪除剪裁區(qū)域机错,您調(diào)用該方法之前必須保存當前的圖形狀態(tài)(使用CGContextSaveGState函數(shù))爬范。當你不再需要剪裁區(qū)域,然后您可以使用CGContextRestoreGState函數(shù)恢復之前的屬性和剪裁區(qū)域。usesEvenOddFillRule屬性用來確定區(qū)域封閉的路徑是用單雙數(shù)原則還是非零的規(guī)則弱匪。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


Hit Detection->碰撞檢測

- containsPoint:

Returns a Boolean value indicating whether the area enclosed by the receiver contains the specified point.->返回一個布爾值表示接收機包圍的區(qū)域是否包含指定的點青瀑。

Declaration

譯:聲明

<code>
SWIFT
func containsPoint(_ point: CGPoint) -> Bool
OBJECTIVE-C
- (BOOL)containsPoint:(CGPoint)point
</code>
Parameters
point | The point to test against the path, specified in the path object's coordinate system.->在路徑的對象坐標系統(tǒng)中是否包含指定的點。
Return Value|YES 如果在路徑閉合區(qū)域中萧诫,否則 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 usesEvenOddFillRuleproperty to determine which parts of the subpath would be filled.->接收器包含指定的點,如果點在一個子路徑封閉一部分中,通常會在填充操作中被涂畫斥难。該方法使用usesEvenOddFillRuleproperty的值來確定子路徑哪些部分會填充。
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.->如果點在一個未關(guān)閉子路徑里面财搁,那么點不被認為可以封閉路徑蘸炸,不管這個區(qū)域是否被填充操作涂畫。因此,為了確定鼠標點擊打開路徑,在調(diào)用這個方法之前尖奔,您必須創(chuàng)建一個路徑的復制對象和顯式地關(guān)閉任何子路徑(使用closePath方法)。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


empty (Property/屬性)

A Boolean value indicating whether the path has any valid elements. (read-only)->一個表示路徑是否有有效元素的布爾值穷当。

Declaration

譯:聲明

<code>
SWIFT
var empty: Bool { get }OBJECTIVE-C
@property(readonly, getter=isEmpty) BOOL empty
</code>

Discussion

Valid path elements include commands to move to a specified point, draw a line or curve segment, orclose the path. Thus, a path is not considered empty even if all you do is call the moveToPoint: method.->有效路徑元素包括轉(zhuǎn)移到一個指定的點命令,畫一條直線或曲線段命令或者關(guān)閉路徑命令提茁。因此,路徑不被認為是空的,即使你做的是調(diào)用moveToPoint:方法。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


bounds (Property/屬性)

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

Declaration

譯:聲明

<code>
SWIFT
var bounds: CGRect { get }
OBJECTIVE-C
@property(nonatomic, readonly) CGRect bounds
</code>

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.->在這個屬性的值是完全包含路徑所有點的最小矩形,包括任何貝塞爾曲線和二次曲線的控制點馁菜。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用

Applying Transformations

- applyTransform:

Transforms all points in the path using the specified affine transform matrix.->使用指定的仿射變換矩陣,轉(zhuǎn)換路徑中的所有點

Declaration

譯:聲明

<code>
SWIFT
func applyTransform(_ transform: CGAffineTransform)
OBJECTIVE-C
- (void)applyTransform:(CGAffineTransform)transform
Parameters
transform | The transform matrix to apply to the path.->提供給路徑的轉(zhuǎn)換矩陣
</code>

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.->這種方法提供指定迅速轉(zhuǎn)換路徑點茴扁。路徑對象的修改是永久性的。如果你不想永久地修改路徑對象時,您應該考慮到用一個副本轉(zhuǎn)換汪疮。

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用


Constants->常量

  • UIRectCorner

    The corners of a rectangle.->矩形角落

Declaration

譯:聲明

<code>
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;
</code>

Constants->常量
  • UIRectCornerTopLeft

The top-left corner of the rectangle.->矩形左上角
Available in iOS 3.2 and later.->iOS 3.2以后適用

  • UIRectCornerTopRight

The top-right corner of the rectangle.->矩形右上角
Available in iOS 3.2 and later.->iOS 3.2以后適用

  • UIRectCornerBottomLeft

The bottom-left corner of the rectangle.->矩形左下角
Available in iOS 3.2 and later.->iOS 3.2以后適用

  • UIRectCornerBottomRight

The bottom-right corner of the rectangle.->矩形右下角
Available in iOS 3.2 and later.->iOS 3.2以后適用

  • UIRectCornerAllCorners

All corners of the rectangle.->矩形所有角
Available in iOS 3.2 and later.->iOS 3.2以后適用

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ù)表示在默認坐標系(原點在左上角和向右和向下都是正值)沒有被反射轉(zhuǎn)換修改的矩形幾個角落峭火。


Import Statement

->導入聲明

  • OBJECTIVE-C

@import UIKit;

  • SWIFT

import UIKit

Availability

Available in iOS 3.2 and later.->iOS 3.2以后適用

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市智嚷,隨后出現(xiàn)的幾起案子卖丸,更是在濱河造成了極大的恐慌,老刑警劉巖盏道,帶你破解...
    沈念sama閱讀 206,013評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件稍浆,死亡現(xiàn)場離奇詭異,居然都是意外死亡猜嘱,警方通過查閱死者的電腦和手機衅枫,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,205評論 2 382
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來朗伶,“玉大人弦撩,你說我怎么就攤上這事÷劢裕” “怎么了益楼?”我有些...
    開封第一講書人閱讀 152,370評論 0 342
  • 文/不壞的土叔 我叫張陵猾漫,是天一觀的道長。 經(jīng)常有香客問我偏形,道長静袖,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 55,168評論 1 278
  • 正文 為了忘掉前任俊扭,我火速辦了婚禮队橙,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘萨惑。我一直安慰自己捐康,他們只是感情好,可當我...
    茶點故事閱讀 64,153評論 5 371
  • 文/花漫 我一把揭開白布庸蔼。 她就那樣靜靜地躺著解总,像睡著了一般。 火紅的嫁衣襯著肌膚如雪姐仅。 梳的紋絲不亂的頭發(fā)上花枫,一...
    開封第一講書人閱讀 48,954評論 1 283
  • 那天,我揣著相機與錄音掏膏,去河邊找鬼劳翰。 笑死,一個胖子當著我的面吹牛馒疹,可吹牛的內(nèi)容都是我干的佳簸。 我是一名探鬼主播,決...
    沈念sama閱讀 38,271評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼颖变,長吁一口氣:“原來是場噩夢啊……” “哼生均!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起腥刹,我...
    開封第一講書人閱讀 36,916評論 0 259
  • 序言:老撾萬榮一對情侶失蹤马胧,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后肛走,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體漓雅,經(jīng)...
    沈念sama閱讀 43,382評論 1 300
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 35,877評論 2 323
  • 正文 我和宋清朗相戀三年朽色,在試婚紗的時候發(fā)現(xiàn)自己被綠了邻吞。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 37,989評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡葫男,死狀恐怖抱冷,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情梢褐,我是刑警寧澤旺遮,帶...
    沈念sama閱讀 33,624評論 4 322
  • 正文 年R本政府宣布赵讯,位于F島的核電站,受9級特大地震影響耿眉,放射性物質(zhì)發(fā)生泄漏边翼。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,209評論 3 307
  • 文/蒙蒙 一鸣剪、第九天 我趴在偏房一處隱蔽的房頂上張望组底。 院中可真熱鬧,春花似錦筐骇、人聲如沸债鸡。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,199評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽厌均。三九已至,卻和暖如春告唆,著一層夾襖步出監(jiān)牢的瞬間棺弊,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 31,418評論 1 260
  • 我被黑心中介騙來泰國打工擒悬, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留镊屎,地道東北人。 一個月前我還...
    沈念sama閱讀 45,401評論 2 352
  • 正文 我出身青樓茄螃,卻偏偏與公主長得像,于是被迫代替她去往敵國和親连锯。 傳聞我的和親對象是個殘疾皇子归苍,可洞房花燭夜當晚...
    茶點故事閱讀 42,700評論 2 345

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

  • 聶處約網(wǎng)友 文/白烏鴉 聶處與一倩女網(wǎng)聊近一年 聶處本也是名牌大學畢業(yè) 又干文秘出身網(wǎng)聊自是文彩飛揚 終一日,引得...
    南倚閑坐閱讀 340評論 0 0
  • 在平時上臺說話或者演講時运怖,一些人總是說自己沒有自信拼弃,我也是這樣的,但是后來聽到了一些技巧摇展,覺得還有幾分道理吻氧,我說給...
    本喜爾玉閱讀 718評論 0 0
  • A spectacular and breath-taking scene is being shown on t...
    JudyDuan閱讀 186評論 0 0