我需要绘制一个六边形,并用图像作为模式填充颜色。 我所做的:CoreGraphics FillPath和描边路径
CGContextSaveGState(context);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextSetFillColorWithColor(context, [[UIColor colorWithPatternImage:[UIImage imageNamed:@"patternerba.png"]] CGColor]);
CGContextSetStrokeColorWithColor(context, [[UIColor blackColor] CGColor]);
CGContextSetLineWidth(context, 3.0);
// drawing hexagon here...
CGContextStrokePath(context);
CGContextFillPath(context);
[[NSString stringWithFormat:@"Foo"] drawAtPoint:innerRect.origin withFont:[UIFont fontWithName:@"Helvetica" size:16]];
CGContextRestoreGState(context);
但从CGContextStrokePath和CGContextFillPath的顺序根据,我得到一个六边形接壤,但没有填充或填充但不接壤。我怎样才能解决这个问题?
增加CGContextSetLineWidth中的宽度.. – 2012-02-22 15:29:55