iOS画线

作者: _Jock羁 | 来源:发表于2017-01-11 10:26 被阅读538次
- (void)drawline:(CGContextRef)context
      startPoint:(CGPoint)startPoint
       stopPoint:(CGPoint)stopPoint
           color:(UIColor *)color
       lineWidth:(double)lineWitdth
            dash:(BOOL)flag {
    CGContextSetStrokeColorWithColor(context, color.CGColor);
    CGContextSetLineWidth(context, lineWitdth);
    if (flag == YES) {
        CGFloat lengths[] = {4,10};
        CGContextSetLineDash(context, 0, lengths, 2);  //画虚线
    }
    if (flag == NO) {
        CGFloat lengths[] = {0,0};
        CGContextSetLineDash(context, 0, lengths, 0);
    }
    CGContextBeginPath(context);
    CGContextMoveToPoint(context, startPoint.x, startPoint.y);
    CGContextAddLineToPoint(context, stopPoint.x,stopPoint.y);
    CGContextStrokePath(context);
}

相关文章

  • iOS 画线

    1.iOS画虚线边框layer.border 2.iOS画小于1px的细线 3.iOS 设置行距,并且计算有行距的...

  • iOS画线

  • iOS CAShapeLayer & UIBezierPath画

    iOS CAShapeLayer & UIBezierPath画线、画图[https://www.cnblogs....

  • iOS CAShapeLayer & UIBezierPath画

    参考笔者博客或者博客: [iOS CAShapeLayer & UIBezierPath画线、画图: https:...

  • iOS离散点画曲线

    在iOS开发过程中,我们会经常遇到画线的功能,比如线性图。 目前iOS画线有两大类方法 (我所知道的)。1、基于C...

  • iOS swift 画线

    需要继承UIView 重写draw 方法 //自定义View

  • iOS 画线-圆

    画实线、虚线圆 .h .m 用法 效果图

  • ios绘图基础

    ios常见的图形绘制 画线 画圆、圆弧 画矩形,画椭圆,多边形 画图片 画文字 1:ios绘图基础 几个基本的概念...

  • iOS ----Core Graphics(1):画线

    demo地址:https://github.com/allenchann/CWLGraphics drawRect...

  • Quartz2D

    学习链接 IOS CGContext用法 Quartz2D 绘图 画线的三个步骤: 获取上下文 绘图 渲染 参考链...

网友评论

      本文标题:iOS画线

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