Skip to content

Commit 172c069

Browse files
author
li.x
committed
2 parents 7122c89 + 5fc5ad7 commit 172c069

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,44 @@
11
# LxThroughPointsBezier
22
Draw a smooth bezier through several points you designated. The curve‘s bend level is adjustable.
3+
Installation
4+
------------
5+
You only need drag UIBezierPath+LxThroughPointsBezier.h and UIBezierPath+LxThroughPointsBezier.m to your project.
6+
Support
7+
------------
8+
Minimum support iOS version: iOS 5.0
9+
How to use
10+
-----------
11+
#import "UIBezierPath+LxThroughPointsBezier.h"
12+
###
13+
CGPoint point1 = CGPointMake(30, 180);
14+
CGPoint point2 = CGPointMake(90, 120);
15+
CGPoint point3 = CGPointMake(120, 200);
16+
CGPoint point4 = CGPointMake(160, 240);
17+
CGPoint point5 = CGPointMake(210, 160);
18+
CGPoint point6 = CGPointMake(240, 300);
19+
CGPoint point7 = CGPointMake(290, 140);
20+
21+
NSValue * point1Value = [NSValue valueWithCGPoint:point1];
22+
NSValue * point2Value = [NSValue valueWithCGPoint:point2];
23+
NSValue * point3Value = [NSValue valueWithCGPoint:point3];
24+
NSValue * point4Value = [NSValue valueWithCGPoint:point4];
25+
NSValue * point5Value = [NSValue valueWithCGPoint:point5];
26+
NSValue * point6Value = [NSValue valueWithCGPoint:point6];
27+
NSValue * point7Value = [NSValue valueWithCGPoint:point7];
28+
29+
_pointArray = [NSMutableArray array];
30+
[_pointArray addObjectsFromArray:@[point1Value, point2Value, point3Value, point4Value, point5Value, point6Value, point7Value]];
31+
32+
_curve = [UIBezierPath bezierPath];
33+
[_curve addCurvesThroughPoints:_pointArray];
34+
35+
_shapeLayer = [CAShapeLayer layer];
36+
_shapeLayer.strokeColor = [UIColor blueColor].CGColor;
37+
_shapeLayer.fillColor = nil;
38+
_shapeLayer.lineWidth = 3;
39+
_shapeLayer.path = _curve.CGPath;
40+
[_view.layer addSublayer:_shapeLayer];
41+
Be careful
42+
-----------
43+
The good bend level is about 0.6 ~ 0.8. The default and recommended value is 0.7.
44+
You must wrap CGPoint struct to NSValue object, and give at least 2 point for drawing the curve.

0 commit comments

Comments
 (0)