标签:
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