贝塞尔曲线

-(void)drawTrianglePath

{

    UIBezierPath *payh = [UIBezierPath bezierPath];

    

    [payh moveToPoint:CGPointMake(10, 20)];

    

    [payh addLineToPoint:CGPointMake(300, 20)];

    

    [payh addLineToPoint:CGPointMake(150, 150)];

    

    [payh closePath];

    

    

    //设置线条宽度

    

    payh.lineWidth = 2.0;

    

    

    //填充色必须设置在画笔颜色前边

    

    //设置填充颜色

    UIColor *color = [UIColor greenColor];

    [color set];

    [payh fill];

    

    

    //设置画笔颜色

    

    UIColor *strokeColor = [UIColor blueColor];

    [strokeColor set];

    [payh stroke];

    


}

//正方形

-(void)drawRectPath

{

    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(10, 150, 100, 100)];

    

    path.lineWidth = 1.5;

    

    path.lineCapStyle = kCGLineCapRound;

    

    path.lineJoinStyle = kCGLineJoinBevel;

    

    UIColor *color = [UIColor redColor];

    [color set];

    [path fill];

    

    [path stroke];

    


}

//画圆(椭圆)

-(void)drawCircle

{

    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(10, 10, 120, 200)];

    path.lineWidth = 2.0;

    

    UIColor *color = [UIColor blueColor];

    

    [color set];

    

    [path fill];

    [path closePath];




}

//圆角

-(void)drawCorner

{

    //矩形的某个角是圆角  CGSizeMake用来指定水平和垂直方向的半径大小

    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 20, 100, 100) byRoundingCorners:UIRectCornerTopLeft cornerRadii:CGSizeMake(100, 20)];

    //矩形四个角都为圆角

    UIBezierPath *path1 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 10, 150, 150) cornerRadius:10];

    

    

    path.lineWidth = 1.5;

    

    UIColor *color = [UIColor redColor];

    [color set];

    

    [path stroke];

    

    [path closePath];

}

//画弧

-(void)drawRadian

{

    //startAngle(开始的角度)endAngle(结束的角度)   clockwise(是否顺时针画弧);

    

    float PI = 3.1415926;

    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 100) radius:100 startAngle:(PI*22)/180 endAngle:(PI*180)/180 clockwise:NO];

    

    path.lineWidth = 1.5;

    

    UIColor *color = [UIColor redColor];

    [color set];

    

    [path stroke];

    

    [path closePath];

    

}

//二次贝塞尔曲线(起点+控制点(控制点起牵引作用未必一定要经过)+结束点)

-(void)drawSecondBezierPath

{


    UIBezierPath *path = [UIBezierPath bezierPath];

    

    //首先设置起始点

    

    [path moveToPoint:CGPointMake(10, 10)];

    

    //添加曲线

    

    [path addQuadCurveToPoint:CGPointMake(220, 150) controlPoint:CGPointMake(150, 10)];

    

    

    path.lineWidth = 1.5;

    

    UIColor *color = [UIColor redColor];

    [color set];

    [path stroke];

    [path closePath];


}

//三次贝塞尔曲线(道理同上只是多了一个控制点)

-(void)drawThirdBezierPath

{

    UIBezierPath *path = [UIBezierPath bezierPath];

    

    [path moveToPoint:CGPointMake(10, 150)];

    

    [path addCurveToPoint:CGPointMake(330, 150) controlPoint1:CGPointMake(120, 20) controlPoint2:CGPointMake(220, 230)];

    

    path.lineWidth = 1.5;

    

    UIColor *color = [UIColor redColor];

    [color set];

    [path stroke];

    [path closePath];




}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值