我写了一个CALayer的子类,重写了方法:- (void)drawInContext:(CGContextRef)ctx。但是 CGContextSetRGBFillColor 不能工作,非常糟糕。救命,救命!
- (void)drawInContext:(CGContextRef)ctx
{
//CGContextSaveGState(ctx);
for (int i = 0; i < pointArray.count-1; i++)
{
HQPoint *point = [pointArray objectAtIndex:i];
HQPoint *pointNext = [pointArray objectAtIndex:i+1];
CGContextMoveToPoint(ctx, point.piontX, point.piontY);
CGContextAddLineToPoint(ctx, pointNext.piontX, pointNext.piontY);
}
CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
CGContextSetLineWidth(ctx, 1);
CGContextStrokePath(ctx);
//CGContextRestoreGState(ctx);
}