2012-11-01 99 views
0

我有这个代码来为内部和外部边界之间的区域着色。核心图形剪裁不起作用

CGContextSaveGState(context); 
CGContextAddRect(context, self.bounds); 
CGContextAddPath(context, inlinePath); 
CGContextEOClip(context); 
CGContextAddPath(context, outlinePath); 
CGContextClip(context); 
CGContextSetFillColorWithColor(context, _myColor.CGColor); 
CGContextFillRect(context, self.bounds); 
CGContextRestoreGState(context); 

这是当地例行程序drawChartInContext:的一部分。

UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 2.0); 
[self drawChartInContext:UIGraphicsGetCurrentContext()]; 
UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

但是,当我把它从drawRect我只是得到充满_myColor整个outlinePath区域:
它,当我生成这样的图像的伟大工程。

- (void)drawRect:(CGRect)rect 
{ 
    CGContextRef context = UIGraphicsGetCurrentContext(); 
    [self drawChartInContext:context]; 
} 

什么可能是错的?

回答

0

只是想通了。这是2级的疏忽的组合:

  1. inlinePath过零区(即有效的特殊情况)
  2. myColor有1.0α(配置错误)。