//------------------1.绘制线条--------------------------
/*
//获取当前绘制的“画笔”
CGContextRef ctx = UIGraphicsGetCurrentContext();
//设置线条的宽度
CGContextSetLineWidth(ctx, 2);
//设置画笔画线的颜色
// CGColorCreateGenericRGB(<#CGFloat red#>, <#CGFloat green#>, <#CGFloat blue#>, <#CGFloat alpha#>)
CGContextSetStrokeColorWithColor(ctx, [UIColor redColor].CGColor);
[[UIColor redColor] setStroke];
//将画笔移动到某一个点上
CGContextMoveToPoint(ctx, 20, 20);
//添加一条线
CGContextAddLineToPoint(ctx, 120, 20);
CGContextAddLineToPoint(ctx, 120, 200);
CGPoint p1 = {120,20};
CGPoint p2 = {120,200};
CGPoint p3 = {220,200};
CGPoint points[] = {p1,p2,p3};
//计算数组中的元素个数
int count = sizeof(points)/sizeof(CGPoint);
//绘制多个线条
CGContextAddLines(ctx, points, count);
//绘制图形
CGContextDrawPath(ctx, kCGPathStroke);
*/
//--------------------2.绘制矩形----------------------------------
// //获取当前绘制的画笔
// CGContextRef ctx = UIGraphicsGetCurrentContext();
//
// //设置线条的宽度
// CGContextSetLineWidth(ctx, 2);
//
// //设置画笔的颜色
// CGContextSetStrokeColorWithColor(ctx, [UIColor redColor].CGColor);
//
// //设置填充的颜色
// CGContextSetFillColorWithColor(ctx, [UIColor greenColor].CGColor);
// [[UIColor greenColor] setFill];
//
// //将画笔移动到某一个点上
// CGContextMoveToPoint(ctx, 20, 20);
//
// //添加一个矩形
// CGContextAddRect(ctx, CGRectMake(10, 10, 100, 200));
//
// //绘制图形
// /*
// 绘制模式
// kCGPathFill 填充绘制
// kCGPathStroke 画线
// kCGPathFillStroke 填充并且画线
// */
//
// CGContextDrawPath(ctx, kCGPathFillStroke);
//-----------------3.绘制曲线----------------------------------------
/*
//获取当前绘制的画笔
CGContextRef ctx = UIGraphicsGetCurrentContext();
//设置线条的宽度
CGContextSetLineWidth(ctx, 2);
//设置画笔画线的颜色
CGContextSetStrokeColorWithColor(ctx, [UIColor redColor].CGColor);
CGContextMoveToPoint(ctx, 20, 20);
CGContextAddCurveToPoint(ctx, 100, 20,
200, 300,
300, 50);
CGContextAddQuadCurveToPoint(ctx, 140, 20,
300, 200);
CGContextDrawPath(ctx, kCGPathStroke);
*/
//-----------------4.通过PaintCode绘制生成的代码------------------------
/*
Color Declarations
UIColor* color4 = [UIColor colorWithRed: 1 green: 0.114 blue: 0.114 alpha: 1];
Star Drawing
UIBezierPath* starPath = [UIBezierPath bezierPath];
[starPath moveToPoint: CGPointMake(44, 15.5)];
[starPath addLineToPoint: CGPointMake(51.23, 24.76)];
[starPath addLineToPoint: CGPointMake(63.5, 27.94)];
[starPath addLineToPoint: CGPointMake(55.7, 36.84)];
[starPath addLineToPoint: CGPointMake(56.05, 48.06)];
[starPath addLineToPoint: CGPointMake(44, 44.3)];
[starPath addLineToPoint: CGPointMake(31.95, 48.06)];
[starPath addLineToPoint: CGPointMake(32.3, 36.84)];
[starPath addLineToPoint: CGPointMake(24.5, 27.94)];
[starPath addLineToPoint: CGPointMake(36.77, 24.76)];
[starPath closePath];
[color4 setFill];
[starPath fill];
[[UIColor blackColor] setStroke];
starPath.lineWidth = 1;
[starPath stroke];
*/
Bezier Drawing
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
[[UIColor redColor] setStroke];
bezierPath.lineWidth = 1;
[bezierPath stroke];
Bezier 2 Drawing
UIBezierPath* bezier2Path = [UIBezierPath bezierPath];
[bezier2Path moveToPoint: CGPointMake(18.5, 13.5)];
[bezier2Path addCurveToPoint: CGPointMake(75.4, 37.47) controlPoint1: CGPointMake(56.81, 15.87) controlPoint2: CGPointMake(45.78, 51.69)];
[bezier2Path addCurveToPoint: CGPointMake(61.5, 75.5) controlPoint1: CGPointMake(120.77, 15.69) controlPoint2: CGPointMake(61.5, 75.5)];
[[UIColor redColor] setStroke];
bezier2Path.lineWidth = 1;
[bezier2Path stroke];
Bezier 3 Drawing
UIBezierPath* bezier3Path = [UIBezierPath bezierPath];
[bezier3Path moveToPoint: CGPointMake(143.5, 18.5)];
[bezier3Path addCurveToPoint: CGPointMake(140.5, 84.5) controlPoint1: CGPointMake(210.5, 45.5) controlPoint2: CGPointMake(55.57, 66.51)];
[bezier3Path addCurveToPoint: CGPointMake(169.5, 55.5) controlPoint1: CGPointMake(225.43, 102.49) controlPoint2: CGPointMake(135.05, 67.68)];
[[UIColor redColor] setStroke];
bezier3Path.lineWidth = 1;
[bezier3Path stroke];