美文网首页
UIBezierPath绘制虚线

UIBezierPath绘制虚线

作者: WSGNSLog | 来源:发表于2018-08-14 09:05 被阅读193次

    设置路径的描边模式。

    - (void)setLineDash:(nullable const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase;
    

    pattern

    C样式的浮点值数组,包含线段和模式中的间隙的长度(以点为单位)。 数组中的值交替,从第一个线段长度开始,后跟第一个间隙长度,后跟第二个线段长度,依此类推。

    count

    模式中的值的数量,即虚线数组元素个数。

    phase

    虚线开始的位置:开始绘制图案的偏移量,沿着虚线图案的点测量。 例如,图案5-2-3-2的相位值6将导致绘图在第一个间隙的中间开始。

    示例-虚线绘制一个圆:

    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(100,100) radius:100 startAngle:0 endAngle:M_PI*2 clockwise:YES];
    CGFloat dashLineConfig[] = {4.0, 2.0, 8.0, 2.0,16.0,2.0};
    [path setLineDash:dashLineConfig count:6 phase:0];
    path.lineWidth = 1;
    [path stroke];

    相关文章

      网友评论

          本文标题:UIBezierPath绘制虚线

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