美文网首页
IOS 直线绘制

IOS 直线绘制

作者: JakieZhang | 来源:发表于2016-12-21 09:51 被阅读214次

    //1.创建贝塞尔路径的实例

    UIBezierPath*path = [UIBezierPathbezierPath];

    //2.勾勒一个图形

    //移动画笔

    [pathmoveToPoint:CGPointMake(50,50)];

    //加一条线到260 260的位置

    [pathaddLineToPoint:CGPointMake(250,50)];

    [pathaddLineToPoint:CGPointMake(250,150)];

    [pathaddLineToPoint:CGPointMake(50,150)];

    //[path addLineToPoint:CGPointMake(50, 50)];

    //[path closePath];

    //[path moveToPoint:CGPointMake(50, 200)];

    //[path addLineToPoint:CGPointMake(250, 200)];

    //[path addLineToPoint:CGPointMake(250, 350)];

    //[path addLineToPoint:CGPointMake(50, 350)];

    //[path closePath];

    //3.设置描边色填充色

    [[UIColorredColor]setStroke];

    [[UIColorgreenColor]setFill];

    //设置描边的宽度

    path.lineWidth=10;

    //焦点的样式

    /*

    kCGLineJoinMiter,

    kCGLineJoinRound,

    kCGLineJoinBevel

    */

    path.lineJoinStyle=kCGLineJoinBevel;

    //线两端的样式

    /*

    kCGLineCapButt,

    kCGLineCapRound,

    kCGLineCapSquare

    */

    path.lineCapStyle=kCGLineCapSquare;

    //4.描边及填充

    [pathstroke];

    //[path fill];

    相关文章

      网友评论

          本文标题:IOS 直线绘制

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