首页 > 其他 > 详细

绘制虚线

时间:2015-12-19 13:44:58      阅读:279      评论:0      收藏:0      [点我收藏+]
  UIImageView *dottedLineView = [[UIImageView alloc]initWithFrame:CGRectMake(25, 130, GetWindowsFrameWidth - 50, 2)];
    [self addSubview:dottedLineView];
    
    UIGraphicsBeginImageContext(dottedLineView.frame.size);   //开始画线
    [dottedLineView.image drawInRect:CGRectMake(0, 0, dottedLineView.frame.size.width, dottedLineView.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);  //设置线条终点形状
    
    CGFloat lengths[] = {3,3};
    CGContextRef line = UIGraphicsGetCurrentContext();
    CGContextSetStrokeColorWithColor(line, [UIColor grayColor].CGColor);
    
    CGContextSetLineDash(line, 0, lengths, 2);  //画虚线
    CGContextMoveToPoint(line, 0.0, 2.0);    //开始画线
    CGContextAddLineToPoint(line, GetWindowsFrameWidth - 48, 2.0);
    CGContextStrokePath(line);
    
    dottedLineView.image = UIGraphicsGetImageFromCurrentImageContext();

 

绘制虚线

原文:http://www.cnblogs.com/10-19-92/p/5058995.html

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