CLOSE SEARCH

[Snippet] Draw Bezier Line using Quartz (태극마크)

– (void)drawBezierLine:(CGContextRef)context
{

CGContextSetRGBStrokeColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetLineWidth(context, 2.0);

CGContextAddEllipseInRect(context, CGRectMake(60, 20, 200, 200));
CGContextSetRGBFillColor(context, 0.0, 0.0, 1.0, 1.0);
CGContextDrawPath(context, kCGPathFillStroke);
CGContextStrokePath(context);

CGPoint start = CGPointMake(60.0, 120.0);
CGPoint controlPoint1 = CGPointMake(130.0, 230.0);
CGPoint controlPoint2 = CGPointMake(190.0, 10.0);
CGPoint end = CGPointMake(260.0, 120.0);

CGContextMoveToPoint(context, start.x, start.y);
CGContextAddCurveToPoint(context, controlPoint1.x, controlPoint1.y, controlPoint2.x, controlPoint2.y, end.x, end.y);
CGContextSaveGState(context);

CGContextAddArc(context, 160, 120, 100, 0, M_PI, true);
CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
CGContextDrawPath(context, kCGPathFillStroke);
CGContextStrokePath(context);

}

Filed under: iOS