Uibezierpath is used in drawing, custom animation tracks.
Uibezierpath has many classes of methods that can create basic curves, such as the method of creating an elliptical path using a rect: Bezierpathwithovalinrect.
1. See how to draw a fan path
Uibezierpath *piepath = [Uibezierpathbezierpath]; [Piepath Movetopoint:center]; [Piepath addarcwithcenter:center radius:radius startangle:topangle endangle:endangle clockwise: YES]; [Piepath Closepath];
Note that the use of moveToPoint and closepath here, without these 2 words, path is just an arc, not a fan.
2. Cropping with path
Addclip Features in Uibezierpath:
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.
Simply put, after a path calls Addclip, the visible area of its context becomes its "fill area", and the next draw is ignored if it is outside the domain.
For example, if you add a piece of code to the top of the code, you can draw the arc instead of the fan:
Uibezierpath *circlepath = [Uibezierpath bezierpathwithovalinrect:outcirclerect]; Uibezierpath *innercirclepath = [Uibezierpath bezierpathwithovalinrect:innercirclerect]; [Circlepath Appendpath:innercirclepath]; [Circlepath Setusesevenoddfillrule:yes]; Then there will be a description [Circlepath Addclip];
3.usesEvenOddFillRule How to determine "Fill area" (Fill region)
How to determine the fill area of a closed path, Apple provides 2 methods through the Usesevenoddfillrule property,
if YES , the path is filled using the even-odd rule. if NO , it is filled using the Non-zero rule. Both rules is 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 all path line is then Interp reted as follows:
-
For the even-odd rule, if the total number of the path crossings was odd, the point is considered to be inside the path and the corresponding is filled. If the number of crossings is even, the point was considered to being outside the path and the region are not filled.
-
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 a S-1. If the sum of the crossings is nonzero, the point was considered to being inside the path and the corresponding region is fill Ed. If The sum is 0, the point is outside the path and the region are not filled.
Simply put, the first, even-odd, to judge a point in the fill area, need from this point, to a point outside the region to draw a ray, if the ray and the odd number of paths intersect, then this is in the fill area, conversely, not.
The second, is also the painting ray, according to the path of the clockwise and counter-clockwise count, if and not 0, is in the fill area, and vice versa, not.
4.containsPoint: Determine if a point is included
The receiver contains the specified point if, point was in a portion of a closed subpath this would normally be painted During a fill operation.
Reprint: http://www.cnblogs.com/breezemist/p/3487770.html
IOS Uibezierpath Knowledge Introduction