IOS Bezier Curve (Uibezierpath) Properties, method collation _ios

Source: Internet
Author: User

A detailed explanation of IOS Bezier curve

Development of iOS Friends are aware of the importance of iOS Bezier curve, as often used in such things, simply draw time to the corresponding all the attributes, methods to make a summary.

Uibezierpath is primarily used to draw vector graphics, which is based on the core graphics pair of CGPATHREF data types and path drawing properties of a package, so it is necessary graphics context (CGCONTEXTREF), So the general Uibezierpath is used in DrawRect.

Introduction to Uibezierpath Properties:

1.CGPath: Converts the Uibezierpath class to Cgpath, similar to the Uicolor Cgcolor

2.empty: Read-only type, is there a valid element on the path

3.bounds: It's not the same as the view bounds, which gets the x, y, and width of the path, but the height is 0

4.currentPoint: The location of the current path can be understood as the end of path

5.linewidth:path width

6.linecapstyle:path endpoint style, with 3 styles

Kcglinecapbutt: no point

Kcglinecapround: Round Ends

Kcglinecapsquare: Square endpoint (style is the same as Kcglinecapbutt, but a bit longer than Kcglinecapbutt)

Effect Chart:

    

7.lineJoinStyle: Corner Style

Kcglinejoinmiter: Sharp Corner

Kcglinejoinround: Rounded Corners

Kcglinejoinbevel: Missing angle

Effect Chart:

    

8.miterLimit: Maximum miter length (only valid when using Kcglinejoinmiter), the smaller the angle of the corner, the greater the miter length

To avoid too long miter length, use the Linelimit property limit, and if the miter length exceeds miterlimit, the corners are displayed in Kcalinejoinbevel type

9.flatness: Bending path of the rendering accuracy, the default is 0.6, the smaller the higher the precision, the corresponding more consumption of performance.

10.usesEvenOddFillRule: The single double loop rule is used to draw the path, and the default is No.

Uirectcorner: Pt.

Uirectcornertopleft: Top left corner

Uirectcornertopright: Top Right corner

Uirectcornerbottomleft: Lower left corner

Uirectcornerbottomright: Lower right corner

Uirectcornerallcorners: all Four Corners

Introduction to the Uibezierpath method:

1. Create Uibezierpath objects:

+ (instancetype) Bezierpath:

2. Create a rectangle within the rect:

+ (Instancetype) Bezierpathwithrect: (cgrect) Rect:

Parameter:rect-> frame of rectangle

3. Create the inscribed curve in RECT:

+ (Instancetype) Bezierpathwithovalinrect: (cgrect) Rect:

Parameter:rect-> frame of rectangle

4. Create a rectangle with rounded corners, and when the rectangle becomes a positive circle, radius no longer works:

+ (Instancetype) Bezierpathwithroundedrect: (cgrect) Rect Cornerradius: (cgfloat) Cornerradius

Parameter:rect-> frame of rectangle

cornerradius-> Fillet Size

5. Set a rectangle with rounded corners for a particular corner:

+ (Instancetype) Bezierpathwithroundedrect: (cgrect) rect byroundingcorners: (uirectcorner) Corners cornerRadii: ( Cgsize) cornerradii

Parameter:rect-> frame of rectangle

Corners-> the rounded corners specified

Cornerradii-> the size of rounded corners

6. Create Arc + (Instancetype) Bezierpathwitharccenter: (cgpoint) Center radius: (cgfloat) Radius startangle: (cgfloat) StartAngle Endangle: (cgfloat) Endangle clockwise: (BOOL) clockwise

Parameter:center-> dot

Radius-> radius

startangle-> Start position

Endangle-> End of the date

Clockwise-> whether the clockwise direction

Starting position reference diagram:

      

7. Create a path from an existing path:

B + (Instancetype) Bezierpathwithcgpath: (cgpathref) Cgpath

Parameter:cgpath-> already has a path

8.init Method:

-(Instancetype) init

9.initWiteCoder Method:

-(Nullable Instancetype) Initwithcoder: (Nscoder *) Adecoder

10. Convert into Cgpath:

-(CGPATHREF) Cgpath

11. Move to a certain point:

-(void) moveToPoint: (cgpoint) point

Parameter:point-> target Location

12. Draw a line:

-(void) Addlinetopoint: (cgpoint) point

Parameter:point-> target Location

13. Create a three-time Bezier curve:

-(void) Addcurvetopoint: (cgpoint) endPoint controlPoint1: (cgpoint) controlPoint1 ControlPoint2: (cgpoint) ControlPoint2

Parameter:endpoint-> Endpoint

Controlpoint1-> Control point 1

Controlpoint2-> Control point 2

Reference Chart:

    

14. Create a two-time Bezier curve:

-(void) Addquadcurvetopoint: (cgpoint) endPoint controlpoint: (cgpoint) ControlPoint

Parameter:endpoint-> Endpoint

Controlpoint-> Control Point

Reference Chart:

     

15. Add Arc:

-(void) Addarcwithcenter: (cgpoint) Center radius: (cgfloat) Radius startangle: (cgfloat) startangle endangle: (cgfloat) Endangle clockwise: (BOOL) clockwise

Parameters: See Creating arcs

16. Closed path, that is, a line at the end point and the starting point:

-(void) Closepath;

17. Clear the Path:

-(void) removeallpoints;

18. Append Path:

-(void) Appendpath: (Uibezierpath *) Bezierpath

Parameter:bezierpath-> the appended path

19. Reversing the path, where the starting point becomes the end point and the end becomes the beginning:

-(Uibezierpath *) Bezierpathbyreversingpath

20. Path for affine transformation:

-(void) Applytransform: (cgaffinetransform) transform;

Parametric:transform-> affine transformation

21. Draw the dotted line:

-(void) Setlinedash: (Nullable const CGFLOAT *) pattern count: (Nsinteger) Count phase: (cgfloat) phase

Parameters: Pattern->c Type linear data

Number of data in Count->pattern

phase-> Start position

22. Fill:

-(void) Fill

23. Strokes, path creation requires strokes to display:

-(void) stroke;

24. Set stroke color, you need to call the stroke method after setting:

[[Uicolor Blackcolor] setstroke];

25. Set the fill color, you need to call the Fill method after setting

[[Uicolor Redcolor] setfill];

26. Set Stroke Blending mode:

-(void) Fillwithblendmode: (cgblendmode) Blendmode Alpha: (cgfloat) Alpha

Parameter:blendmode-> blending mode

alpha-> Transparency

27. Set the blending mode for the fill:

-(void) Strokewithblendmode: (cgblendmode) Blendmode Alpha: (cgfloat) Alpha;

Parameter:blendmode-> blending mode

alpha-> Transparency

28. Modifying the drawing area of the current graphics context is visible, and subsequent drawing operations cause the rendered content to occur only in the populated area of the specified path

-(void) addclip;

GitHub Address: Https://github.com/Locking-Xu/UIBezierPath

Thank you for reading, I hope to help you, thank you for your support for this site!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.