本篇文章主要介绍了"iOS开发 贝塞尔曲线UIBezierPath",主要涉及到方面的内容,对于IOS开发感兴趣的同学可以参考一下:
最近项目中需要用到用贝塞尔曲线去绘制路径 ,然后往路径里面填充图片,找到这篇文章挺好,记录下来 自己学习! 转至 http://blog.csdn.net/gu...
#define pi 3.14159265359 #define DEGREES_TO_RADIANS(degrees) ((pi * degrees)/ 180)
- (void)drawRect:(CGRect)rect
{
UIColor *color = [UIColor redColor];
[color set]; //设置线条颜色 UIBezierPath* aPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150)
radius:75 startAngle:0 endAngle:DEGREES_TO_RADIANS(135)
clockwise:YES];
aPath.lineWidth = 5.0;
aPath.lineCapStyle = kCGLineCapRound; //线条拐角
aPath.lineJoinStyle = kCGLineCapRound; //终点处理 [aPath stroke];
}

6、UIBezierPath类提供了添加二次贝塞尔曲线和三次贝塞尔曲线的支持。
曲线段在当前点开始,在指定的点结束。曲线的形状有开始点,结束点,一个或者多个控制点的切线定义。下图显示了两种曲线类型的相似,以及控制点和curve形状的关系。
(1)绘制二次贝塞尔曲线
使用到这个方法:
Appends a quadratic Bézier curve tothe receiver’s path.
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint
Parameters
endPoint
The endpointofthecurve.
controlPoint
The control point ofthe curve.

demo代码: