+ (UIBezierPath *)bezierPathWithRect:(CGRect)rect
//根據矩形框的內切圓畫曲線
+ (UIBezierPath *)bezierPathWithOvalInRect:(CGRect)rect
+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect cornerRadius:(CGFloat)cornerRadius
//在矩形中,可以針對四角中的某個角加圓角
+ (UIBezierPath *)bezierPathWithRoundedRect:(CGRect)rect byRoundingCorners:(UIRectCorner)corners cornerRadii:(CGSize)cornerRadii
參數:
corners:枚舉值,可以選擇某個角
cornerRadii:圓角的大小
參數:
center:弧線中心點的坐標
radius:弧線所在圓的半徑
startAngle:弧線開始的角度值
endAngle:弧線結束的角度值
clockwise:是否順時針畫弧線
- (void)addQuadCurveToPoint:(CGPoint)endPoint controlPoint:(CGPoint)controlPoint
參數:
endPoint:曲線的終點
controlPoint:畫曲線的基准點
例子:UIBezierPath *movePath = [UIBezierPath bezierPath];
CGPoint fromPoint = self.imageView.center;
CGPoint endPoint = CGPointMake(280, 400);
[movePath moveToPoint:fromPoint]; //開始點
[movePath addQuadCurveToPoint:endPoint controlPoint:CGPointMake(280,0)]; //畫二元曲線,結束點、控制點
- (void)addCurveToPoint:(CGPoint)endPoint controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2
參數:
endPoint:曲線的終點
controlPoint1:畫曲線的第一個基准點
controlPoint2:畫曲線的第二個基准點
//自己創建一段曲線
UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(0, 100)];//開始點
[path addLineToPoint:CGPointMake(300, 100)];//向這條線上加點
[path addLineToPoint:CGPointMake(300, 200)];