美文网首页
UIBezierPath

UIBezierPath

作者: 你飞跃俊杰 | 来源:发表于2019-12-30 16:55 被阅读0次

    UIBezierPath是对CGContextRef的封装, 方法名称有相识的地方
    基本

    //画笔
    UIBezierPath * path = [UIBezierPath bezierPath];
      //把路径添加到上下文
    CGContextAddPath(ctx, bezierPath.CGPath);
     //渲染上下文(layer)
    CGContextStrokePath(ctx);
    

    设置

     [path1 setLineWidth:5];//框
     [path1 stroke];//填充
    

    画线

     [path moveToPoint:CGPointMake(45,45)];
    [path addLineToPoint:CGPointMake(20, 45)];
     [path addLineToPoint:CGPointMake(45, 20)];
    

    画圆

     [path addArcWithCenter:CGPointMake(45, 45) radius:5 startAngle:0 endAngle:M_PI*1.5 clockwise:YES];
    

    弧度:通过控制点(ControlPoint来改变直线的弧度)

     [bezierPath addQuadCurveToPoint:CGPointMake(100, 250) controlPoint:CGPointMake(50, 250)];
    

    画一条线

        UIBezierPath *bezierPath = [UIBezierPath bezierPath];
        [bezierPath moveToPoint:CGPointMake( x1+width*1.0, y)];
        [bezierPath addLineToPoint:CGPointMake(x2-width*1.0, y)];
        CGContextSetLineWidth(context, 1);
        [color setStroke];
        
        CGContextAddPath(context, bezierPath.CGPath);
        CGContextStrokePath(context);
    
    [UIBezierPath bezierPathWithArcCenter:center radius:100 startAngle:0 endAngle:M_PI_2 clockwise:YES];
    

    相关文章

      网友评论

          本文标题:UIBezierPath

          本文链接:https://www.haomeiwen.com/subject/bupmoctx.html