0
在我的项目中,我需要使用Quartz绘画来绘制几百个矩形。我确实有这样的代码最好的方法来绘制多个矩形?
-(void)RenderRectangles:(NSArray*)rectangles
fillColor:(UIColor*)fillColor
strokeColor:(UIColor*)strokeColor
strokeThickness:(float)strokeThickness;
{
CGContextRef context = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(context);
CGContextSetStrokeColorWithColor(context, [strokeColor CGColor]);
CGContextSetLineWidth(context, strokeThickness);
for (NSValue *vRect in rectangles) {
CGContextAddRect(context, [vRect CGRectValue]);
}
CGContextStrokePath(context);
CGContextSetFillColorWithColor(context, [fillColor CGColor]);
for (NSValue *vRect in rectangles) {
CGContextFillRect(context, [vRect CGRectValue]);
}
UIGraphicsPopContext();
}
它工作正常,但我只是想知道是否有可能使用只有一个循环吗?还是有更好的方法来描边和填充矩形的集合?
Thx
这是很好的知道。谢谢 – Eugen