首页 > 其他 > 详细

画虚线

时间:2016-05-13 08:13:27      阅读:107      评论:0      收藏:0      [点我收藏+]

//画虚线

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

画虚线

原文:http://www.cnblogs.com/xiaolingling1126/p/5484946.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!