//画虚线
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
float sizeWidth = rect.size.width;
float sizeHeight = rect.size.height;
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextBeginPath(context);
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor grayColor].CGColor);
CGFloat lengths[] = {10,5};
CGContextSetLineDash(context, 0, lengths,2);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, sizeWidth,0);
CGContextAddLineToPoint(context, sizeWidth,sizeHeight);
CGContextAddLineToPoint(context, 0,sizeHeight);
CGContextAddLineToPoint(context, 0,0);
CGContextStrokePath(context);
}
本文出自 “ZhuoKing” 博客,请务必保留此出处http://9951038.blog.51cto.com/9941038/1747468
原文:http://9951038.blog.51cto.com/9941038/1747468