Description: Properties and methods of the beiser curve (UIBezierPath ).

Source: Internet
Author: User

Description: Properties and methods of the beiser curve (UIBezierPath ).

UIBezierPath is mainly used to draw vector Graphics. It is an encapsulation of CGPathRef data type and path drawing attributes based on Core Graphics. Therefore, CGContextRef is required ), therefore, UIBezierPath is generally used in drawRect.

 

UIBezierPath attributes:

1. CGPath: Convert the UIBezierPath class to CGPath, which is similar to the CGColor of UIColor.

2. empty: Read-Only type. Is there any valid element in the path?

3. bounds: it is different from the view bounds. It obtains the X, Y, and width of the path, but the height is 0.

4. currentPoint: the position of the current path. It can be understood as the end point of the path.

5. lineWidth: path width

6. lineCapStyle: path endpoint style. Three styles are available.

KCGLineCapButt: No endpoint

KCGLineCapRound: Circular endpoint

KCGLineCapSquare: Square endpoint (the style is the same as that of kCGLineCapButt, but it is a little longer than kCGLineCapButt)

:

    

7. lineJoinStyle: corner Style

KCGLineJoinMiter: tip

KCGLineJoinRound: rounded corner

KCGLineJoinBevel: unavailable

:

    

   

8. miterLimit: Maximum diagonal length (valid only when kCGLineJoinMiter is used). The smaller the corner angle, the larger the diagonal length.

 

To avoid the length of the oblique connection, use the lineLimit attribute. If the length of the oblique connection exceeds miterLimit, the corner is displayed in the KCALineJoinBevel type.

 

9. flatness: Specifies the rendering accuracy of the curved path. The default value is 0.6. The smaller the value, the higher the precision, the more performance consumption.

10. usesEvenOddFillRule: determines whether a single or double number circle rule is used to draw a path. The default value is NO.

11. UIRectCorner: corner

UIRectCornerTopLeft: upper left corner

UIRectCornerTopRight: upper right corner

UIRectCornerBottomLeft: lower left

UIRectCornerBottomRight: bottom right corner

UIRectCornerAllCorners: all four corners

 

UIBezierPath:

1. Create a UIBezierPath object:

+ (Instancetype) bezierPath:

2. Create a rectangle in the rect:

+ (Instancetype) bezierPathWithRect :( CGRect) rect:

Parameter: rect-> rectangular Frame

3. Create the inner tangent curve in the rect:

+ (Instancetype) bezierPathWithOvalInRect :( CGRect) rect:

Parameter: rect-> rectangular Frame

4. Create a rectangle with rounded corners. When the rectangle turns into a positive circle, Radius will no longer work:

+ (Instancetype) bezierPathWithRoundedRect :( CGRect) rect cornerRadius :( CGFloat) cornerRadius

Parameter: rect-> rectangular Frame

CornerRadius-> rounded corner size

5. Set the specific corner to the rounded rectangle:

+ (Instancetype) bezierPathWithRoundedRect :( CGRect) rect byRoundingCorners :( UIRectCorner) corners cornerRadii :( CGSize) cornerRadii

Parameter: rect-> rectangular Frame

Corners-> specified rounded corner

CornerRadii-> rounded corner size

6. Create an 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

Clockwise-> clockwise

Start position reference diagram:

      

7. Create a path from an existing path:

B + (instancetype) bezierPathWithCGPath :( CGPathRef) CGPath

Parameter: CGPath-> existing path

 

8. init method:

-(Instancetype) init

9. initWiteCoder method:

-(Nullable instancetype) initWithCoder :( NSCoder *) aDecoder

10. Convert to 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 besell curve:

-(Void) addCurveToPoint :( CGPoint) endPoint controlPoint1 :( CGPoint) controlPoint1 controlPoint2 :( CGPoint) controlPoint2

Parameter: endPoint-> endPoint

ControlPoint1-> Control Point 1

ControlPoint2-> Control Point 2

Reference figure:

    

 

14. Create a secondary besell curve:

-(Void) addQuadCurveToPoint :( CGPoint) endPoint controlPoint :( CGPoint) controlPoint

Parameter: endPoint-> endPoint

ControlPoint-> Control Point

Reference figure:

     

 

15. Add an arc:

-(Void) addArcWithCenter :( CGPoint) center radius :( CGFloat) radius startAngle :( CGFloat) startAngle endAngle :( CGFloat) endAngle clockwise :( BOOL) clockwise

Parameters: see create an arc.

16. Closed Path, that is, connecting a line at the end and the start point:

-(Void) closePath;

17. Clear Path:

-(Void) removeAllPoints;

18. append path:

-(Void) appendPath :( UIBezierPath *) bezierPath

Parameter: bezierPath-> append path

19. Reverse the path, that is, the start point is changed to the end point, and the end point is changed to the start point:

-(UIBezierPath *) bezierPathByReversingPath

20. Path-based affine transformation:

-(Void) applyTransform :( CGAffineTransform) transform;

Parameter: transform-> Affine Transformation

21. Draw the dotted line:

-(Void) setLineDash :( nullable const CGFloat *) pattern count :( NSInteger) count phase :( CGFloat) phase

Parameter: pattern-> C linear data

Count-> Number of data in pattern

Phase-> Start position

22. Fill:

-(Void) fill

23. Stroke. To create a path, you must draw the stroke to display it:

-(Void) stroke;

24. To set the 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 the hybrid mode of stroke:

-(Void) fillWithBlendMode :( CGBlendMode) blendMode alpha :( CGFloat) alpha

Parameter: blendMode-> hybrid mode

Alpha-> Transparency

27. Set the fill mixed mode:

-(Void) strokeWithBlendMode :( CGBlendMode) blendMode alpha :( CGFloat) alpha;

Parameter: blendMode-> hybrid mode

Alpha-> Transparency

28. Modify the drawing area of the current drawing context to be visible. Subsequent drawing operations cause the rendering content to only occur in the filling Area of the specified path.

-(Void) addClip;

GitHub address: https://github.com/Locking-Xu/UIBezierPath

 

This article reprinted to: http://www.cnblogs.com/small-octopus/p/4874600.html

@ Locking_Xu's blog

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.