zoukankan      html  css  js  c++  java
  • 画虚线

    //画虚线

        CAShapeLayer *shapeLayer = [CAShapeLayer layer];

        [shapeLayer setBounds:self.backView.bounds];

        [shapeLayer setPosition:self.backView.center];

        [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];

        

        // 设置虚线颜色为blackColor

        [shapeLayer setStrokeColor:[[UIColor blackColor] CGColor]];

        [shapeLayer setStrokeColor:[[UIColor colorWithRed:223/255.0 green:223/255.0 blue:223/255.0 alpha:1.0f] CGColor]];

        

        // 3.0f设置虚线的宽度

        [shapeLayer setLineWidth:0.5f];

        [shapeLayer setLineJoin:kCALineJoinRound];

        

        // 3=线的宽度 1=每条线的间距

        [shapeLayer setLineDashPattern:

         [NSArray arrayWithObjects:[NSNumber numberWithInt:4],

          [NSNumber numberWithInt:2],nil]];

        

        //设置path

        CGMutablePathRef path = CGPathCreateMutable();

        CGPathMoveToPoint(path, NULL, self.coupNumberLabel.frame.origin.x + self.coupNumberLabel.frame.size.width, 10);//x  虚线的x轴起点  y  虚线的y轴起点

        CGPathAddLineToPoint(path, NULL,self.coupNumberLabel.frame.origin.x + self.coupNumberLabel.frame.size.width,164/2 - 10);   //x  虚线的X轴起点   y  虚线的高度

        [shapeLayer setPath:path];

        CGPathRelease(path);

        

        [[self layer] addSublayer:shapeLayer];

  • 相关阅读:
    Alpha冲刺Day5
    Alpha冲刺Day4
    Alpha冲刺Day3
    团队作业——随堂小测
    Alpha冲刺Day2
    Alpha冲刺Day1
    团队项目需求分析
    结对项目第二次作业
    Linux中exec命令相关
    .lib和.dll文件
  • 原文地址:https://www.cnblogs.com/xiaolingling1126/p/5484946.html
Copyright © 2011-2022 走看看