• 画虚线


    //画虚线

        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];

  • 相关阅读:
    3.4 抓取猫眼电影排行
    2.5 代理的基本原理
    第二章 爬虫基础
    1.8 爬虫框架的安装
    Python序列化
    CVE-2020-1938 Apache-Tomcat-Ajp漏洞复现
    Python定制类
    Apache Tomcat DDOS
    内网端口转发工具
    内网渗透思路简单介绍
  • 原文地址:https://www.cnblogs.com/xiaolingling1126/p/5484946.html
Copyright © 2020-2023  润新知