iOS绘制虚线

-(void)drawRect:(CGRect)rect{
    CGContextRef cont = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(cont, RGB(238, 234, 252).CGColor);
    CGContextSetLineWidth(cont, 1);
    CGFloat lengths[] = {8,5};
    CGContextSetLineDash(cont, 0, lengths, 2);  //画虚线
    CGContextBeginPath(cont);
    CGContextMoveToPoint(cont, 10*RatioWidth, rect.size.height - 1);    //开始画线
    CGContextAddLineToPoint(cont, rect.size.width-10*RatioWidth, rect.size.height - 1);
    CGContextStrokePath(cont);
}

 

posted @ 2017-04-05 16:59  听风gcl  阅读(140)  评论(0编辑  收藏  举报